SDK for PHP 3.x

Validator
in package

Validates a schema against a hash of input.

Table of Contents

Methods

__construct()  : mixed
validate()  : mixed
Validates the given input against the schema.

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.

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.

On this page