CRUDlex\EntityValidator¶
- 
class EntityValidator¶
- Performs validation of the field values of the given Entity. - 
property entity¶
- protected Entity - The entity to validate. 
 - 
property definition¶
- protected EntityDefinition - The entities definition. 
 - 
fieldTypeToRules($field, AbstractData $data, Validator $validator)¶
- Builds up the validation rules for a single field according to the entity definition type. - Parameters: - $field (string) – the field for the rules
- $data (AbstractData) – the data instance to use for validation
- $validator (Validator) – the validator to use
 - Returns: - array the validation rules for the field 
 - 
fieldConstraintsToRules($field, AbstractData $data)¶
- Builds up the validation rules for a single field according to the entity definition constraints. - Parameters: - $field (string) – the field for the rules
- $data (AbstractData) – the data instance to use for validation
 - Returns: - array the validation rules for the field 
 - 
buildUpRules(AbstractData $data, Validator $validator)¶
- Builds up the validation rules for the entity according to its definition. - Parameters: - $data (AbstractData) – the data instance to use for validation
- $validator (Validator) – the validator to use
 - Returns: - array the validation rules for the entity 
 - 
buildUpData()¶
- Builds up the data to validate from the entity. - Returns: - array a map field to raw value 
 - 
validate(AbstractData $data, $expectedVersion)¶
- Validates the entity against the definition. - Parameters: - $data (AbstractData) – the data access instance used for counting things
- $expectedVersion (integer) – the version to perform the optimistic locking check on
 - Returns: - 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). 
 
- 
property