我们已经尝试了几种验证密码的解决方案,但没有一个有效,但用户登录后,所有验证都可以正常工作,除了密码中的字母数字验证。
这是代码:
'password' => array ('required' => array (
'rule' => array ('notEmpty'),
'rule' => array ('between',1,15 ),
//'rule' => array('custom', '[a-zA-Z0-9, ]+'),
'message' => 'A password is required,must be between 8 to 15 characters' )
),
使用自定义功能它不起作用所以我们尝试了
'alphaNumeric' => array(
'rule' => array('alphaNumericDashUnderscore'),
'rule' => 'alphaNumeric',
'required' => true,
'message' => 'password must contain Alphabets and numbers only'
)),
模型中的自定义函数
public function alphaNumericDashUnderscore($check) {
$value = array_values($check);
$value = $value[0];
return preg_match('|^[0-9a-zA-Z_-]*$|', $value);
}
我们正在开发 cakephp 版本 2.4.3