Could not find validation handler 1

Hi,

Based on following line from CakePHP:

trigger_error(__d('cake_dev', 'Could not find validation handler %s for %s', $this->_rule, $field), E_USER_WARNING);

And rules for the field:

'number' => array(
            'required' => true,
            'isUnique' => array('rule' => 'isUnique', 'on' => 'create'),
            'notBlank' => array('rule' => 'notBlank'),
            'maxLength' => array('rule' => array('maxLength', 15)))

CakePHP detects required => true as a rule! When I remove that line, everything works fine!

Note: the field already exists into the data:

$data = array(
	'name' => 'xxx',
	'fields' => 'xxx',
	'startYear' => '999',
	'biography' => 'xxx',
	'headquarter' => 'xxx',
	'number' => '(999) 9999-9999',
	'tags' => 'xxx',
	'updateTime' => '9999999999'
)

How can I fix that problem?

Is this Cake 2? If so, the required key goes in the rule definition:

'number' => [
  'isUnique' => [
    'required' => true, // here
    'rule' => 'isUnique',
    'on' => 'create'
  ]
]

Thanks Jeremy. You saved me.

1 Like