Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

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