When I save the information from a registration form I have some validation rules on the username and email fields (I've pasted the rules below). Validation is called automatically with the saveAll() function.
The problem is that the isUnique rule on the username field doesn't work at all (doesn't return any error). The other rules for this field work just fine, and the unique validation for the email field also works. I can't seem to figure out why this is happening, when the two rules are basically the same.
var $validate = array(
'username' => array(
'isUnique' => array (
'rule' => 'isUnique',
'message' => 'This username already exists.'),
'custom' => array (
'rule' => array('custom', '/^[A-Za-z0-9,\.-_]*$/i'),
'message' => 'The username can only contain letters, numbers, _, - and .'),
'minLength' => array(
'rule' => VALID_NOT_EMPTY,
'message' => 'You must fill in the username.')
),
'email' => array(
'isUnique' => array (
'rule' => 'isUnique',
'message' => 'This email address already exists in our database.'),
'valid' => array (
'rule' => array('email', false),
'message' => 'Invalid email.'),
'minLength' => array(
'rule' => VALID_NOT_EMPTY,
'message' => 'You must fill in the email address.')
)
);