PHP 클래스 CRUDlex\EntityValidator

파일 보기 프로젝트 열기: philiplb/crudlex 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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