SchemaValidator
in package
implements
ValidatorInterface
Default parameter validator
Table of Contents
Interfaces
- ValidatorInterface
- Validator responsible for preparing and validating parameters against the parameter's schema
Properties
- $castIntegerToStringType : bool
- $errors : array<string|int, mixed>
- $instance : self
Methods
- __construct() : mixed
- getErrors() : array<string|int, mixed>
- Get the errors encountered while validating
- getInstance() : self
- validate() : bool
- Validate a value against the acceptable types, regular expressions, minimum, maximums, instanceOf, enums, etc Add default and static values to the passed in variable. If the validation completes successfully, the input must be run correctly through the matching schema's filters attribute.
- determineType() : string|bool
- From the allowable types, determine the type that the variable matches
- recursiveProcess() : bool
- Recursively validate a parameter
Properties
$castIntegerToStringType
protected
bool
$castIntegerToStringType
Whether or not integers are converted to strings when an integer is received for a string input
$errors
protected
array<string|int, mixed>
$errors
Errors encountered while validating
$instance
protected
static self
$instance
Cache instance of the object
Methods
__construct()
public
__construct([bool $castIntegerToStringType = true ]) : mixed
Parameters
- $castIntegerToStringType : bool = true
-
Set to true to convert integers into strings when a required type is a string and the input value is an integer. Defaults to true.
getErrors()
Get the errors encountered while validating
public
getErrors() : array<string|int, mixed>
Return values
array<string|int, mixed>getInstance()
public
static getInstance() : self
Tags
Return values
selfvalidate()
Validate a value against the acceptable types, regular expressions, minimum, maximums, instanceOf, enums, etc Add default and static values to the passed in variable. If the validation completes successfully, the input must be run correctly through the matching schema's filters attribute.
public
validate(Parameter $param, mixed &$value) : bool
Parameters
- $param : Parameter
-
Schema that is being validated against the value
- $value : mixed
-
Value to validate and process. The value may change during this process.
Return values
bool —Returns true if the input data is valid for the schema
determineType()
From the allowable types, determine the type that the variable matches
protected
determineType(string $type, mixed $value) : string|bool
Parameters
- $type : string
-
Parameter type
- $value : mixed
-
Value to determine the type
Return values
string|bool —Returns the matching type on
recursiveProcess()
Recursively validate a parameter
protected
recursiveProcess(Parameter $param, mixed &$value[, string $path = '' ][, int $depth = 0 ]) : bool
Parameters
- $param : Parameter
-
API parameter being validated
- $value : mixed
-
Value to validate and validate. The value may change during this validate.
- $path : string = ''
-
Current validation path (used for error reporting)
- $depth : int = 0
-
Current depth in the validation validate
Return values
bool —Returns true if valid, or false if invalid