Documentation

ContextualValidatorInterface

A validator in a specific execution context.

Tags
author

Bernhard Schussek bschussek@gmail.com

Table of Contents

Methods

atPath()  : $this
Appends the given path to the property path of the context.
getViolations()  : ConstraintViolationListInterface
Returns the violations that have been generated so far in the context of the validator.
validate()  : $this
Validates a value against a constraint or a list of constraints.
validateProperty()  : $this
Validates a property of an object against the constraints specified for this property.
validatePropertyValue()  : $this
Validates a value against the constraints specified for an object's property.

Methods

atPath()

Appends the given path to the property path of the context.

public atPath(string $path) : $this

If called multiple times, the path will always be reset to the context's original path with the given path appended to it.

Parameters
$path : string
Return values
$this

validate()

Validates a value against a constraint or a list of constraints.

public validate(mixed $value[, Constraint|array<string|int, Constraint>|null $constraints = null ][, string|GroupSequence|array<string|int, string|GroupSequence>|null $groups = null ]) : $this

If no constraint is passed, the constraint is assumed.

Parameters
$value : mixed

The value to validate

$constraints : Constraint|array<string|int, Constraint>|null = null

The constraint(s) to validate against

$groups : string|GroupSequence|array<string|int, string|GroupSequence>|null = null

The validation groups to validate. If none is given, "Default" is assumed

Return values
$this

validateProperty()

Validates a property of an object against the constraints specified for this property.

public validateProperty(object $object, string $propertyName[, string|GroupSequence|array<string|int, string|GroupSequence>|null $groups = null ]) : $this
Parameters
$object : object
$propertyName : string

The name of the validated property

$groups : string|GroupSequence|array<string|int, string|GroupSequence>|null = null

The validation groups to validate. If none is given, "Default" is assumed

Return values
$this

validatePropertyValue()

Validates a value against the constraints specified for an object's property.

public validatePropertyValue(object|string $objectOrClass, string $propertyName, mixed $value[, string|GroupSequence|array<string|int, string|GroupSequence>|null $groups = null ]) : $this
Parameters
$objectOrClass : object|string

The object or its class name

$propertyName : string

The name of the property

$value : mixed

The value to validate against the property's constraints

$groups : string|GroupSequence|array<string|int, string|GroupSequence>|null = null

The validation groups to validate. If none is given, "Default" is assumed

Return values
$this

        
On this page

Search results