Class

eZ\Publish\Core\FieldType\Validator

abstract class Validator

Base field type validator validator.

Methods

getConstraintsSchema()

Returns a schema for supported validator configurations.

mixed validateConstraints(mixed $constraints)

bool validate(Value $value)

Perform validation on $value.

ValidationError[] getMessage()

Returns array of messages on performed validations.

initializeWithConstraints(array $constraints)

Initialized an instance of Validator, with earlier configured constraints.

mixed __get(string $name)

Magic getter.

__set(string $name, mixed $value)

Magic setter.

Details

at line 78
public getConstraintsSchema()

Returns a schema for supported validator configurations.

This implementation returns a three dimensional map containing for each validator configuration referenced by identifier a map of supported parameters which are defined by a type and a default value (see example). Example: array( 'stringLength' => array( 'minStringLength' => array( 'type' => 'int', 'default' => 0, ), 'maxStringLength' => array( 'type' => 'int' 'default' => null, ) ), ); The validator identifier.

at line 88
abstract public mixed validateConstraints(mixed $constraints)

Parameters

mixed $constraints

Return Value

mixed

at line 103
abstract public bool validate(Value $value)

Perform validation on $value.

Will return true when all constraints are matched. If one or more constraints fail, the method will return false.

When a check against a constraint has failed, an entry will be added to the $errors array.

Parameters

Value $value

Return Value

bool

at line 112
public ValidationError[] getMessage()

Returns array of messages on performed validations.

When no validation errors occurred, the returned array should be empty.

Return Value

ValidationError[]

at line 126
public initializeWithConstraints(array $constraints)

Initialized an instance of Validator, with earlier configured constraints.

Parameters

array $constraints

at line 154
public mixed __get(string $name)

Magic getter.

Returns constraint value, from its $name.

Parameters

string $name

Return Value

mixed

Exceptions

PropertyNotFoundException

at line 172
public __set(string $name, mixed $value)

Magic setter.

Sets $value to constraint, identified by $name.

Parameters

string $name
mixed $value

Exceptions

PropertyNotFoundException