PHP Класс CRUDlex\EntityValidator

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$definition The entities definition.
$entity The entity to validate.

Открытые методы

Метод Описание
__construct ( Entity $entity ) Constructor.
validate ( AbstractData $data, integer $expectedVersion ) : array Validates the entity against the definition.

Защищенные методы

Метод Описание
buildUpData ( ) : array Builds up the data to validate from the entity.
buildUpRules ( AbstractData $data, Valdi\Validator $validator ) : array Builds up the validation rules for the entity according to its definition.
fieldConstraintsToRules ( string $field, AbstractData $data ) : array Builds up the validation rules for a single field according to the entity definition constraints.
fieldTypeToRules ( string $field, AbstractData $data, Valdi\Validator $validator ) : array Builds up the validation rules for a single field according to the entity definition type.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( Entity $entity )
$entity Entity the entity to validate

buildUpData() защищенный Метод

Builds up the data to validate from the entity.
protected buildUpData ( ) : array
Результат array a map field to raw value

buildUpRules() защищенный Метод

Builds up the validation rules for the entity according to its definition.
protected buildUpRules ( AbstractData $data, Valdi\Validator $validator ) : array
$data AbstractData the data instance to use for validation
$validator Valdi\Validator the validator to use
Результат array the validation rules for the entity

fieldConstraintsToRules() защищенный Метод

Builds up the validation rules for a single field according to the entity definition constraints.
protected fieldConstraintsToRules ( string $field, AbstractData $data ) : array
$field string the field for the rules
$data AbstractData the data instance to use for validation
Результат array the validation rules for the field

fieldTypeToRules() защищенный Метод

Builds up the validation rules for a single field according to the entity definition type.
protected fieldTypeToRules ( string $field, AbstractData $data, Valdi\Validator $validator ) : array
$field string the field for the rules
$data AbstractData the data instance to use for validation
$validator Valdi\Validator the validator to use
Результат array the validation rules for the field

validate() публичный Метод

Validates the entity against the definition.
public validate ( AbstractData $data, integer $expectedVersion ) : array
$data AbstractData the data access instance used for counting things
$expectedVersion integer the version to perform the optimistic locking check on
Результат array an array with the fields "valid" and "errors"; valid provides a quick check whether the given entity passes the validation and errors is an array with all errored fields as keys and arrays as values; this field arrays contains the actual errors on the field: "boolean", "floating", "integer", "dateTime" (for dates and datetime fields), "inSet", "reference", "required", "unique", "value" (only for the version field, set if the optimistic locking failed).

Описание свойств

$definition защищенное свойство

The entities definition.
protected $definition

$entity защищенное свойство

The entity to validate.
protected $entity