Symfony\Component\Validator\ExecutionContextInterface::validate
Validates the given value within the scope of the current validation.
The value may be any value recognized by the used metadata factory (see ), or an array or a traversable object of such values. Usually you validate a value that is not the current node of the execution context. For this case, you can pass the argument which is appended to the current property path when a violation is created. For example, take the following object graph: <pre> (Person)---($address: Address)---($phoneNumber: PhoneNumber) ^ </pre> When the execution context stops at the <tt>Person</tt> instance, the property path is "address". When you validate the <tt>PhoneNumber</tt> instance now, pass "phoneNumber" as sub path to correct the property path to "address.phoneNumber": <pre> $context->validate($address->phoneNumber, 'phoneNumber'); </pre> Any violations generated during the validation will be added to the violation list that you can access with .
Signature
public function validate(mixed
$value,
[string
$subPath = '',
[array
$groups = null,
[Boolean
$traverse = false,
[Boolean
$deep = false]]]] )
Parameters
$value
— mixed- The value to validate.
$subPath
— string- The path to append to the context's property path.
$groups
— array- The groups to validate in. If you don't pass any
groups here, the current group of the context
will be used. $traverse
— object- Whether to traverse the value if it is an array
or an instance of <tt>\Traversable</tt>. $deep
— object- Whether to traverse the value recursively if
it is a collection of collections.