Re: A simple validation rule not working correctly

2008-01-30 Thread grigri

var $validate = array(
  'password' = array(
'rule' = 'alphanumeric',
'required' = true,
'allowEmpty' = false
  )
);

'required' means that the form field must be submitted, i.e. you can't
add/update this model without specifying that field.

'allowEmpty' means that if the field is present, it must not be blank.

On Jan 30, 12:40 pm, Marcin Jaworski [EMAIL PROTECTED] wrote:
 Try this:

 var $validate = array(
 'password' = array(
 'rule' = 'alphanumeric',
 'required' = true
 )
 );

 On 30 Sty, 11:06, Reny [EMAIL PROTECTED] wrote:

  Hi all,
  I'm using the last beta release and I have this problem:
  I have in my model that validation rules

  var $validate = array(
  'password' = array(
  'alphanumeric'  = array(
  'rule'  = 'alphanumeric',
  'message'   = 'Only 
  alphanumeric allowed',
  ),
  'required'  = array(
  'rule'  = 
  VALID_NOT_EMPTY,
  'message'   = 'This 
  field cannot be
  empty',
  )
  )
  );

  why if I submit form with empty field it's pass validation
  why if I pass non alphanum ie \  it's pass validation

  I have really no idea :(.

  Thanks all.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: A simple validation rule not working correctly

2008-01-30 Thread Marcin Jaworski

Try this:

var $validate = array(
'password' = array(
'rule' = 'alphanumeric',
'required' = true
)
);

On 30 Sty, 11:06, Reny [EMAIL PROTECTED] wrote:
 Hi all,
 I'm using the last beta release and I have this problem:
 I have in my model that validation rules

 var $validate = array(
 'password' = array(
 'alphanumeric'  = array(
 'rule'  = 'alphanumeric',
 'message'   = 'Only alphanumeric 
 allowed',
 ),
 'required'  = array(
 'rule'  = 
 VALID_NOT_EMPTY,
 'message'   = 'This 
 field cannot be
 empty',
 )
 )
 );

 why if I submit form with empty field it's pass validation
 why if I pass non alphanum ie \  it's pass validation

 I have really no idea :(.

 Thanks all.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: A simple validation rule not working correctly

2008-01-30 Thread Reny

On 30 Gen, 13:45, grigri [EMAIL PROTECTED] wrote:
 var $validate = array(
   'password' = array(
 'rule' = 'alphanumeric',
 'required' = true,
 'allowEmpty' = false
   )
 );

ok, thanks, my password arrive in controller (and in model validation
also) not blank, beacuse, I think, I use Auth component: password
arrive in hash format.

If usefull for other I implemented this solution:

i wrote a custom validation:

MODEL:
var $validate = array(
'password' = array(
'unique' = array('rule' = 'validatePassword')),
);



function validatePassword($data) {
$valid = true;
if ($this-data['Utente']['password'] ==
Security::hash(Configure::read('Security.salt') . )) {
$valid = false;
}
return $valid;
}


For cakephp guru: if I wrong tell me :)

regards
Reny


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---