DisjunctionValidator extends AbstractCompositeValidator
Validator to chain many validators in a disjunction (logical or).
Table of Contents
Properties
- $options : array<string|int, mixed>
- $supportedOptions : array<string|int, mixed>
- This contains the supported options, their default values and descriptions.
- $validatedInstancesContainer : SplObjectStorage
- $validators : SplObjectStorage
Methods
- __construct() : mixed
- addValidator() : void
- Adds a new validator to the composition.
- count() : int
- Returns the number of validators contained in this composition.
- getOptions() : array<string|int, mixed>
- Returns the options for this validator
- getValidators() : SplObjectStorage
- Returns the child validators of this Composite Validator
- removeValidator() : void
- Removes the specified validator.
- setOptions() : void
- Receive validator options from framework.
- setValidatedInstancesContainer() : void
- Allows to set a container to keep track of validated instances.
- validate() : Result
- Checks if the given value is valid according to the validators of the disjunction.
- initializeDefaultOptions() : void
- Initialize default options.
Properties
$options
protected
array<string|int, mixed>
$options
= []
$supportedOptions
This contains the supported options, their default values and descriptions.
protected
array<string|int, mixed>
$supportedOptions
= []
$validatedInstancesContainer
protected
SplObjectStorage
$validatedInstancesContainer
Tags
$validators
protected
SplObjectStorage
$validators
Methods
__construct()
public
__construct() : mixed
addValidator()
Adds a new validator to the composition.
public
addValidator(ValidatorInterface $validator) : void
Parameters
- $validator : ValidatorInterface
count()
Returns the number of validators contained in this composition.
public
count() : int
Return values
intgetOptions()
Returns the options for this validator
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getValidators()
Returns the child validators of this Composite Validator
public
getValidators() : SplObjectStorage
Return values
SplObjectStorageremoveValidator()
Removes the specified validator.
public
removeValidator(ValidatorInterface $validator) : void
Parameters
- $validator : ValidatorInterface
Tags
setOptions()
Receive validator options from framework.
public
setOptions(array<string|int, mixed> $options) : void
Parameters
- $options : array<string|int, mixed>
setValidatedInstancesContainer()
Allows to set a container to keep track of validated instances.
public
setValidatedInstancesContainer(SplObjectStorage $validatedInstancesContainer) : void
Parameters
- $validatedInstancesContainer : SplObjectStorage
-
A container to keep track of validated instances
validate()
Checks if the given value is valid according to the validators of the disjunction.
public
validate(mixed $value) : Result
So only one validator has to be valid, to make the whole disjunction valid. Errors are only returned if all validators failed.
Parameters
- $value : mixed
-
The value that should be validated
Return values
ResultinitializeDefaultOptions()
Initialize default options.
protected
initializeDefaultOptions(array<string|int, mixed> $options) : void
Parameters
- $options : array<string|int, mixed>