Validator
in package
This is the validator class.
It's responsible for applying validations against a number of variables.
Table of Contents
- $loader : Loader
- The loader instance.
- $variables : array<string|int, mixed>
- The variables to validate.
- __construct() : void
- Create a new validator instance.
- allowedValues() : Validator
- Assert that each variable is amongst the given choices.
- isBoolean() : Validator
- Assert that each specified variable is a boolean.
- isInteger() : Validator
- Assert that each specified variable is an integer.
- notEmpty() : Validator
- Assert that each variable is not empty.
- assertCallback() : Validator
- Assert that the callback returns true for each variable.
Properties
$loader
The loader instance.
protected
Loader
$loader
$variables
The variables to validate.
protected
array<string|int, mixed>
$variables
Methods
__construct()
Create a new validator instance.
public
__construct(array<string|int, mixed> $variables, Loader $loader) : void
Parameters
- $variables : array<string|int, mixed>
- $loader : Loader
Return values
void —allowedValues()
Assert that each variable is amongst the given choices.
public
allowedValues(array<string|int, string> $choices) : Validator
Parameters
- $choices : array<string|int, string>
Return values
Validator —isBoolean()
Assert that each specified variable is a boolean.
public
isBoolean() : Validator
Return values
Validator —isInteger()
Assert that each specified variable is an integer.
public
isInteger() : Validator
Return values
Validator —notEmpty()
Assert that each variable is not empty.
public
notEmpty() : Validator
Return values
Validator —assertCallback()
Assert that the callback returns true for each variable.
protected
assertCallback(callable $callback[, string $message = 'failed callback assertion' ]) : Validator
Parameters
- $callback : callable
- $message : string = 'failed callback assertion'