Documentation

ValidatorInterface extends MetadataFactoryInterface

Validates PHP values against constraints.

Tags
author

Bernhard Schussek bschussek@gmail.com

Table of Contents

Methods

getMetadataFor()  : MetadataInterface
Returns the metadata for the given value.
hasMetadataFor()  : bool
Returns whether the class is able to return metadata for the given value.
inContext()  : ContextualValidatorInterface
Returns a validator in the given execution context.
startContext()  : ContextualValidatorInterface
Starts a new validation context and returns a validator for that context.
validate()  : ConstraintViolationListInterface
Validates a value against a constraint or a list of constraints.
validateProperty()  : ConstraintViolationListInterface
Validates a property of an object against the constraints specified for this property.
validatePropertyValue()  : ConstraintViolationListInterface
Validates a value against the constraints specified for an object's property.

Methods

hasMetadataFor()

Returns whether the class is able to return metadata for the given value.

public hasMetadataFor(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

validate()

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

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

If no constraint is passed, the constraint is assumed.

Parameters
$value : mixed
$constraints : Constraint|array<string|int, Constraint> = 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
ConstraintViolationListInterface

A list of constraint violations If the list is empty, validation succeeded

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 ]) : ConstraintViolationListInterface
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
ConstraintViolationListInterface

A list of constraint violations If the list is empty, validation succeeded

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 ]) : ConstraintViolationListInterface
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
ConstraintViolationListInterface

A list of constraint violations If the list is empty, validation succeeded


        
On this page

Search results