Documentation

Validator
in package

Validates a schema against a hash of input.

Table of Contents

$constraints  : mixed
$defaultConstraints  : mixed
$errors  : mixed
$path  : mixed
__construct()  : mixed
validate()  : mixed
Validates the given input against the schema.
addError()  : mixed
canJsonEncode()  : mixed
check_blob()  : mixed
check_boolean()  : mixed
check_list()  : mixed
check_map()  : mixed
check_numeric()  : mixed
check_string()  : mixed
check_structure()  : mixed
checkAssociativeArray()  : mixed
checkCanString()  : mixed
dispatch()  : mixed
validateRange()  : mixed

Properties

$constraints

private mixed $constraints = []

$defaultConstraints

private static mixed $defaultConstraints = ['required' => true, 'min' => true, 'max' => false, 'pattern' => false]

Methods

__construct()

public __construct([array<string|int, mixed> $constraints = null ]) : mixed
Parameters
$constraints : array<string|int, mixed> = null

Associative array of constraints to enforce. Accepts the following keys: "required", "min", "max", and "pattern". If a key is not provided, the constraint will assume false.

Return values
mixed

validate()

Validates the given input against the schema.

public validate(string $name, Shape $shape, array<string|int, mixed> $input) : mixed
Parameters
$name : string

Operation name

$shape : Shape

Shape to validate

$input : array<string|int, mixed>

Input to validate

Tags
throws
InvalidArgumentException

if the input is invalid.

Return values
mixed

addError()

private addError(mixed $message) : mixed
Parameters
$message : mixed
Return values
mixed

canJsonEncode()

private canJsonEncode(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

check_blob()

private check_blob(Shape $shape, mixed $value) : mixed
Parameters
$shape : Shape
$value : mixed
Return values
mixed

check_boolean()

private check_boolean(Shape $shape, mixed $value) : mixed
Parameters
$shape : Shape
$value : mixed
Return values
mixed

check_list()

private check_list(ListShape $shape, mixed $value) : mixed
Parameters
$shape : ListShape
$value : mixed
Return values
mixed

check_map()

private check_map(MapShape $shape, mixed $value) : mixed
Parameters
$shape : MapShape
$value : mixed
Return values
mixed

check_numeric()

private check_numeric(Shape $shape, mixed $value) : mixed
Parameters
$shape : Shape
$value : mixed
Return values
mixed

check_string()

private check_string(Shape $shape, mixed $value) : mixed
Parameters
$shape : Shape
$value : mixed
Return values
mixed

checkAssociativeArray()

private checkAssociativeArray(mixed $value) : mixed
Parameters
$value : mixed
Return values
mixed

checkCanString()

private checkCanString(mixed $value) : mixed
Parameters
$value : mixed
Return values
mixed

dispatch()

private dispatch(Shape $shape, mixed $value) : mixed
Parameters
$shape : Shape
$value : mixed
Return values
mixed

validateRange()

private validateRange(Shape $shape, mixed $length, mixed $descriptor) : mixed
Parameters
$shape : Shape
$length : mixed
$descriptor : mixed
Return values
mixed

Search results