PHP Class eZ\Publish\Core\FieldType\Validator

Datei anzeigen Open project: ezsystems/ezpublish-kernel

Protected Properties

Property Type Description
$constraints array Key is the constraint name, value is the default value. If no default value is needed, just set to false. Example: With no default value protected $constraints = array( "maxStringLength" => false ); With a default value protected $constraints = array( "minIntegerValue" => 0, "maxIntegerValue" => 40 );
$constraintsSchema mixed A one dimensional map with validator parameters.
$errors eZ\Publish\SPI\FieldType\ValidationError[] The errors collected during validation.

Public Methods

Method Description
__get ( string $name ) : mixed Magic getter.
__set ( string $name, mixed $value ) Magic setter.
getConstraintsSchema ( ) Returns a schema for supported validator configurations.
getMessage ( ) : eZ\Publish\SPI\FieldType\ValidationError[] Returns array of messages on performed validations.
initializeWithConstraints ( array $constraints ) Initialized an instance of Validator, with earlier configured constraints.
validate ( Value $value ) : boolean Perform validation on $value.
validateConstraints ( mixed $constraints ) : mixed

Method Details

__get() public method

Returns constraint value, from its $name.
public __get ( string $name ) : mixed
$name string
return mixed

__set() public method

Sets $value to constraint, identified by $name.
public __set ( string $name, mixed $value )
$name string
$value mixed

getConstraintsSchema() public method

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.

getMessage() public method

When no validation errors occurred, the returned array should be empty.
public getMessage ( ) : eZ\Publish\SPI\FieldType\ValidationError[]
return eZ\Publish\SPI\FieldType\ValidationError[]

initializeWithConstraints() public method

Initialized an instance of Validator, with earlier configured constraints.
public initializeWithConstraints ( array $constraints )
$constraints array

validate() abstract public method

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.
abstract public validate ( Value $value ) : boolean
$value Value
return boolean

validateConstraints() abstract public method

abstract public validateConstraints ( mixed $constraints ) : mixed
$constraints mixed
return mixed

Property Details

$constraints protected_oe property

Key is the constraint name, value is the default value. If no default value is needed, just set to false. Example: With no default value protected $constraints = array( "maxStringLength" => false ); With a default value protected $constraints = array( "minIntegerValue" => 0, "maxIntegerValue" => 40 );
protected array $constraints
return array

$constraintsSchema protected_oe property

A one dimensional map with validator parameters.
protected mixed $constraintsSchema
return mixed

$errors protected_oe property

The errors collected during validation.
protected ValidationError[],eZ\Publish\SPI\FieldType $errors
return eZ\Publish\SPI\FieldType\ValidationError[]