src/CRUDlex/EntityValidator.php
protected function fieldTypeToRules($field, AbstractData $data, Validator $validator)
    {
        $setItems     = $this->definition->getField($field, 'items', []);
        $rulesMapping = [
            'boolean' => ['boolean'],
            'float' => ['floating'],
            'integer' => ['integer'],
            'date' => ['dateTime', 'Y-m-d'],
            'datetime' => ['or', $validator, ['dateTime', 'Y-m-d H:i'], ['dateTime', 'Y-m-d H:i:s']],
            'set' => array_merge(['inSet'], $setItems),
            'reference' => ['reference', $data, $field],
            'many' => ['many', $data, $field]
        ];
        $type         = $this->definition->getType($field);
        $rules        = [];
        if (array_key_exists($type, $rulesMapping)) {
            $rules[] = $rulesMapping[$type];
        }
        return $rules;
    }
protected function fieldTypeToRules($field, AbstractData $data, Validator $validator)
    {
        $setItems     = $this->definition->getField($field, 'items', []);
        $rulesMapping = [
            'boolean' => ['boolean'],
            'float' => ['floating'],
            'integer' => ['integer'],
            'date' => ['dateTime', 'Y-m-d'],
            'datetime' => ['or', $validator, ['dateTime', 'Y-m-d H:i'], ['dateTime', 'Y-m-d H:i:s']],
            'set' => array_merge(['inSet'], $setItems),
            'reference' => ['reference', $data, $field],
            'many' => ['many', $data, $field]
        ];
        $type         = $this->definition->getType($field);
        $rules        = [];
        if (array_key_exists($type, $rulesMapping)) {
            $rules[] = $rulesMapping[$type];
        }
        return $rules;
    }
protected function fieldTypeToRules ( $ field , AbstractData $ data , Validator $ validator ) { $ setItems = $ this -> definition -> getField ( $ field , 'items' , [ ] ) ; $ rulesMapping = [ 'boolean' => [ 'boolean' ] , 'float' => [ 'floating' ] , 'integer' => [ 'integer' ] , 'date' => [ 'dateTime' , 'Y-m-d' ] , 'datetime' => [ 'or' , $ validator , [ 'dateTime' , 'Y-m-d H:i' ] , [ 'dateTime' , 'Y-m-d H:i:s' ] ] , 'set' => array_merge ( [ 'inSet' ] , $ setItems ) , 'reference' => [ 'reference' , $ data , $ field ] , 'many' => [ 'many' , $ data , $ field ] ] ; $ type = $ this -> definition -> getType ( $ field ) ; $ rules = [ ] ; if ( array_key_exists ( $ type , $ rulesMapping ) ) { $ rules [ ] = $ rulesMapping [ $ type ] ; } return $ rules ; }
Builds up the validation rules for a single field according to the
entity definition type.

@param string $field
the field for the rules
@param AbstractData $data
the data instance to use for validation
@param Validator $validator
the validator to use

@return array
the validation rules for the field
Builds up the validation rules for a single field according to the entity definition type .