AggregateBoundaryValidator
class AggregateBoundaryValidator extends GenericObjectValidator (View source)
A validator which will not validate Aggregates that are lazy loaded and uninitialized.
Validation over Aggregate Boundaries can hence be forced by making the relation to other Aggregate Roots eager loaded.
Note that this validator is not part of the public API and you should not use it manually.
Properties
protected bool | $acceptsEmptyValues | Specifies whether this validator accepts empty values. |
from AbstractValidator |
protected array | $supportedOptions | from GenericObjectValidator | |
protected array | $options | from AbstractValidator | |
protected Result[] | $resultStack | from AbstractValidator | |
protected array | $propertyValidators | from GenericObjectValidator | |
protected SplObjectStorage | $validatedInstancesContainer | from GenericObjectValidator |
Methods
Constructs the validator and sets validation options
Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.
Pop and return the current Result from the stack and make $this->result point to the last Result again.
Get the current Result for this validation invocation. Use this inside your isValid() implementation to e.g. merge results together into the current one.
Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.
Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred. Will skip validation if value is an uninitialized lazy loading proxy.
Creates a new validation error object and adds it to $this->errors
Allows to set a container to keep track of validated instances.
Load the property value to be used for validation.
Checks if the specified property of the given object is valid, and adds found errors to the $messages object.
Adds the given validator for validation of the specified property.
Returns all property validators - or only validators of the specified property
Details
__construct(array $options = [])
Constructs the validator and sets validation options
protected Result
pushResult()
Push a new Result onto the Result stack and return it in order to fix cyclic calls to a single validator.
protected Result
popResult()
Pop and return the current Result from the stack and make $this->result point to the last Result again.
protected Result|null
getResult()
Get the current Result for this validation invocation. Use this inside your isValid() implementation to e.g. merge results together into the current one.
Result
validate(mixed $value)
Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred.
void
isValid(mixed $value)
Checks if the given value is valid according to the validator, and returns the Error Messages object which occurred. Will skip validation if value is an uninitialized lazy loading proxy.
protected void
addError(string $message, int $code, array $arguments = [])
Creates a new validation error object and adds it to $this->errors
array
getOptions()
Returns the options of this validator
final protected bool
isEmpty(mixed $value)
No description
void
setValidatedInstancesContainer(SplObjectStorage $validatedInstancesContainer)
Allows to set a container to keep track of validated instances.
protected bool
isUninitializedProxy($object)
No description
protected bool
isValidatedAlready(object $object)
No description
protected mixed
getPropertyValue(object $object, string $propertyName)
Load the property value to be used for validation.
In case the object is a doctrine proxy, we need to load the real instance first.
protected null|Result
checkProperty(mixed $value, array $validators)
Checks if the specified property of the given object is valid, and adds found errors to the $messages object.
void
addPropertyValidator(string $propertyName, ValidatorInterface $validator)
Adds the given validator for validation of the specified property.
array
getPropertyValidators(string $propertyName = null)
Returns all property validators - or only validators of the specified property