Avolutions\Validation\TypeValidator
extends AbstractValidatorThe TypeValidator validates the data type of the value.
Properties
Property | Visibility | Type | Description |
---|---|---|---|
$Entity | protected | ?\Avolutions\Orm\Entity | The Entity to validate. |
$message | protected | ?string | A custom error message. |
$options | protected | array | An associative array with options. |
$property | protected | ?string | The property of the Entity to validate. |
Methods
Method | Visibility | Description |
---|---|---|
__construct() | public | Creates a new Validator object and set the options. |
getMessage() | public | Returns the error message of the validator. |
getValidatorName() | protected | Returns the name of the validator in lowercase and without suffix 'Validator'. |
isValid() | public | Checks if the passed value is valid considering the validator type and passed options. |
setOptions() | public | Set the passed options, property and Entity to internal properties. |
Property Details
Method Details
__construct()
Creates a new Validator object and set the options.
public
__construct([array<string|int, mixed> $options = [] ][, string|null $property = null ][, Entity|null $Entity = null ]) : mixed
Parameters
array<string|int, mixed>
$options
(optional)
An associative array with options.
string|null
$property
(optional)
The property of the Entity to validate.
Entity|null
$Entity
(optional)
$Entity The Entity to validate.
getMessage()
Returns the error message of the validator.
public
getMessage() : string
Return values
string Returns the error message of the validator.isValid()
Checks if the passed value is valid considering the validator type and passed options.
public
isValid(mixed $value) : bool
Parameters
mixed
$value
The value to validate.
Return values
bool Checks if the passed value is valid considering the validator type and passed options.setOptions()
Set the passed options, property and Entity to internal properties.
public
setOptions([array<string|int, mixed> $options = [] ][, string|null $property = null ][, Entity|null $Entity = null ]) : mixed
Parameters
array<string|int, mixed>
$options
(optional)
An associative array with options.
string|null
$property
(optional)
The property of the Entity to validate.
Entity|null
$Entity
(optional)
The Entity to validate.