For reference here are the custom validation rules I use:

function __validateConfirmPassword($field) {
  $valid = false;
  if ($this->data['User']['password'] ==
Security::hash(Configure::read('Security.salt').
$field['password_confirm']) {
    $valid = true;
  }
  return $valid;
}

function __validatePasswordLength($field) {
  $valid = false;
  if (strlen($this->data['User']['password_confirm']) >= 8) {
    $valid = true;
  }
  return $valid;
}

and my validate array:

var $validate = array(
  'user_group_id' => array('rule' => 'notEmpty'),
  'username' => array(
    'isUnique' => array(
      'rule' => 'isUnique',
      'message' => 'Sorry, this username has been taken, please try
another',
      'last' => true
    ),
    'validChars' => array(
      'rule' => '/^[a-z0-9_]{1,}$/i',
      'message' => 'Can only include letters, numbers and underscores'
    )
  ),
  'password' => array(
    'minLengthCreate' => array(
      'rule' => array('__validatePasswordLength'),
      'message' => 'Must be at least 8 characters long'
    )
  ),
  'password_confirm' => array(
    'notEmpty' => array(
      'rule' => array('notEmpty'),
      'message' => 'This field cannot be left blank',
      'on' => 'create',
      'last' => true
    ),
    'confirm' => array(
      'rule' => array('__validateConfirmPassword'),
      'message' => 'Password confirmation does not match'
    )
  )
);

Hope it's of some use to you,

Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to