Thursday, August 23, 2012

Error when I use the $validate in the model file

What I did

I used the cakePhp

What happened

When I use $validate in the model file to check the user input, the warning information like below:

Warning (2): preg_match(): Delimiter must not be alphanumeric or backslash [CORE\Cake\Model\Validator\CakeValidationRule.php, line 276]

The regular expression does not work.
My environment are PHP 5.4.4, Mysql 5.0.10, apache 2.4.2.

code:
class User Extends AppModel
{

var $name = "User";  public $validate = array(          'username' => array(                  'alphaNumberic' => array(                          'rule'=>'alphaNumberic',                          'require' => 'true',                          'message' => 'numberic and characters only'                  ),                  'between' => array(                          'rule' => array('between', 9, 18),                          'message' => '9-18characters',                  )          ),          'password' => array(                  'alphaNumberic' => array(                          'rule'=>'alphaNumberic',                          'require' => 'true',                          'message' => 'numberic and characters only'                  ),                  'between' => array(                          'rule' => array('between', 9, 18),                          'message' => '9-18characters',                  )          ),          'email' => array(                  'rule'=>'email',                  'message'=>'it is not email'          ),  );  

} ?>

What I expected to happen

I hope the $validate could work correctly.



--
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: