CakePHP 的验证问题

发布于 2024-10-27 10:48:36 字数 1111 浏览 1 评论 0原文

我正在练习 CakePHP 用户注册验证,但我从核心收到一些错误:

Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE/cake/libs/model/model.php, line 2611]

这是验证数组:

var $validate = array (
    'username' => array (
        'ruleUser1'=> array (
            'rule' => 'alphaNumberic',
            'message' => 'The username must be alphanumeric only'
        ),
        'ruleUser2' => array (
            'rule' => 'notEmpty',
            'message' => 'Username can\'t be empty'
        ),
        'ruleUser3' => array (
            'rule' => 'isUnique',
            'message' => 'This username has already been taken.'
        )
    ),
    'password' => array (
        'rulePass1'=> array (
            'rule' => array ('minLength', 8),
            'message' => 'Password must be 8 character length'
        ),
        'rulePass2' => array (
            'rule' => 'notEmpty',
            'message' => 'Password can\'t be empty'
        )
    )
);

我哪里错了?

I'm making practice with CakePHP user registration validation but I get some error from the core:

Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE/cake/libs/model/model.php, line 2611]

This is the validation array:

var $validate = array (
    'username' => array (
        'ruleUser1'=> array (
            'rule' => 'alphaNumberic',
            'message' => 'The username must be alphanumeric only'
        ),
        'ruleUser2' => array (
            'rule' => 'notEmpty',
            'message' => 'Username can\'t be empty'
        ),
        'ruleUser3' => array (
            'rule' => 'isUnique',
            'message' => 'This username has already been taken.'
        )
    ),
    'password' => array (
        'rulePass1'=> array (
            'rule' => array ('minLength', 8),
            'message' => 'Password must be 8 character length'
        ),
        'rulePass2' => array (
            'rule' => 'notEmpty',
            'message' => 'Password can\'t be empty'
        )
    )
);

Where I'm wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城仅有旧梦在 2024-11-03 10:48:36
'username' => array (
    'ruleUser1'=> array (
        'rule' => 'alphaNumberic',
        'message' => 'The username must be alphanumeric only'
    ),

alphaNumberic 应为alphaNumeric。我认为这就是问题的根源?

'username' => array (
    'ruleUser1'=> array (
        'rule' => 'alphaNumberic',
        'message' => 'The username must be alphanumeric only'
    ),

alphaNumberic should be alphaNumeric. I think that is the source of the problem?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文