Stores the validator's state during validation.
For example, let's validate the following object graph:
<pre> (Person)---($firstName: string) \ ($address: Address)---($street: string) </pre>
We validate the <tt>Person</tt> instance, which becomes the "root" of the validation run (see {@link getRoot}). The state of the context after the first step will be like this:
<pre> (Person)---($firstName: string) ^ \ ($address: Address)---($street: string) </pre>
The validator is stopped at the <tt>Person</tt> node, both the root and the value (see {@link getValue}) of the context point to the <tt>Person</tt> instance. The property path is empty at this point (see {@link getPropertyPath}). The metadata of the context is the metadata of the <tt>Person</tt> node (see {@link getMetadata}).
After advancing to the property <tt>$firstName</tt> of the <tt>Person</tt> instance, the state of the context looks like this:
<pre> (Person)---($firstName: string) \ ^ ($address: Address)---($street: string) </pre>
The validator is stopped at the property <tt>$firstName</tt>. The root still points to the <tt>Person</tt> instance, because this is where the validation started. The property path is now "firstName" and the current value is the value of that property.
After advancing to the <tt>$address</tt> property and then to the <tt>$street</tt> property of the <tt>Address</tt> instance, the context state looks like this:
<pre> (Person)---($firstName: string) \ ($address: Address)---($street: string) ^ </pre>
The validator is stopped at the property <tt>$street</tt>. The root still points to the <tt>Person</tt> instance, but the property path is now "address.street" and the validated value is the value of that property.
Apart from the root, the property path and the currently validated value, the execution context also knows the metadata of the current node (see {@link getMetadata}) which for example returns a {@link Mapping\PropertyMetadata} or a {@link Mapping\ClassMetadata} object. he context also contains the validation group that is currently being validated (see {@link getGroup}) and the violations that happened up until now (see {@link getViolations}).
Apart from reading the execution context, you can also use {@link addViolation} or {@link addViolationAt} to add new violations and {@link validate} or {@link validateValue} to validate values that the validator otherwise would not reach.
@author Bernhard Schussek <bschussek@gmail.com>
@api
Expanded class hierarchy of ExecutionContextInterface
All classes that implement ExecutionContextInterface
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExecutionContextInterface:: |
public | function | Adds a violation at the current node of the validation graph. | 1 |
ExecutionContextInterface:: |
public | function | Adds a violation at the validation graph node with the given property path relative to the current property path. | 1 |
ExecutionContextInterface:: |
public | function | Returns the class name of the current node. | 1 |
ExecutionContextInterface:: |
public | function | Returns the validation group that is currently being validated. | 1 |
ExecutionContextInterface:: |
public | function | Returns the metadata for the currently validated value. | 1 |
ExecutionContextInterface:: |
public | function | Returns the used metadata factory. | 1 |
ExecutionContextInterface:: |
public | function | Returns the property name of the current node. | 1 |
ExecutionContextInterface:: |
public | function | Returns the property path to the value that the validator is currently validating. | 1 |
ExecutionContextInterface:: |
public | function | Returns the value at which validation was started in the object graph. | 1 |
ExecutionContextInterface:: |
public | function | Returns the value that the validator is currently validating. | 1 |
ExecutionContextInterface:: |
public | function | Returns the violations generated by the validator so far. | 1 |
ExecutionContextInterface:: |
public | function | Validates the given value within the scope of the current validation. | 1 |
ExecutionContextInterface:: |
public | function | Validates a value against a constraint. | 1 |