Re: Data validation rule (between) never returns true

2010-03-25 Thread WebbedIT
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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com 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.


Re: Data validation rule (between) never returns true

2010-03-25 Thread WebbedIT
Here are my user custom validation methods

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, $reset = false) {
  $valid = false;
  if (strlen($this->data['User']['password_confirm']) >= 8) {
$valid = true;
  }
  return $valid;
}

HTH

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com 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.


Re: Data validation rule (between) never returns true

2010-03-24 Thread timstermatic
@Dr. Loboto Thanks for the answer. That does make sense to me.

@WebbedIT  It also makes sense that providing they match I can take
the confirm_password as the test for password length.

Cheers for the help.




On Mar 24, 9:13 am, WebbedIT  wrote:
> most auth setups also have a password_confirm field and use that to
> validate password length etc.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com 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.


Re: Data validation rule (between) never returns true

2010-03-24 Thread WebbedIT
most auth setups also have a password_confirm field and use that to
validate password length etc.

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com 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.


Re: Data validation rule (between) never returns true

2010-03-23 Thread Dr. Loboto
If you use Auth password field is already hashed so it's length more
then 15 symbols.

On Mar 24, 1:39 am, timstermatic  wrote:
> Hi all,
>
> Here is part of a validate array I have in a model:
>
>               'username' => array(
>                     
> 'loginRule-1'=>array('rule'=>'alphaNumeric','message'=>'Username
> must be alphanumeric - no spaces.' ),
>                     'loginRule-2'=>array('rule' => 
> array('between',5,15),'message'
> => 'Username must be between 5 and 15 characters.'),
>                 ),
>                 'email' => array('rule' => 'email','required' => true),
>                 'password' => array(
>                         
> 'passwordRule-1'=>array('rule'=>'alphaNumeric','message'=>'Password
> must be alphanumeric - no spaces.' ),
>                         'passwordRule-2' => array('rule' => array('between', 
> 5,
> 15),'message' => 'Password must be between 5 to 15 characters' )
>                 )
>
> The final rule in the array "passwordRule-2" always fails and returns
> the message "Password must be between 5 to 15 characters.".
>
> Does anyone have any pointers as to why this is happening.
>
> TIA
>
> Tim

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com 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.


Data validation rule (between) never returns true

2010-03-23 Thread timstermatic
Hi all,

Here is part of a validate array I have in a model:

  'username' => array(

'loginRule-1'=>array('rule'=>'alphaNumeric','message'=>'Username
must be alphanumeric - no spaces.' ),
'loginRule-2'=>array('rule' => 
array('between',5,15),'message'
=> 'Username must be between 5 and 15 characters.'),
),
'email' => array('rule' => 'email','required' => true),
'password' => array(

'passwordRule-1'=>array('rule'=>'alphaNumeric','message'=>'Password
must be alphanumeric - no spaces.' ),
'passwordRule-2' => array('rule' => array('between', 5,
15),'message' => 'Password must be between 5 to 15 characters' )
)

The final rule in the array "passwordRule-2" always fails and returns
the message "Password must be between 5 to 15 characters.".

Does anyone have any pointers as to why this is happening.

TIA

Tim

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com 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.