简体   繁体   English

在Cakephp中设置自定义验证规则时遇到问题

[英]Problem setting custom validation rules in Cakephp

I creating a custom validation rule in my cakephp model. 我在cakephp模型中创建了一个自定义验证规则。

        'article' => array(
                'rule' => '/^[a-z0-9#.,&; ]{2,255}$/i',
                'required' => true,
                'allowEmpty' => false,
                'message' => 'Alphabets and numbers only(3,255).'
        ),

This works fine. 这很好。 But It stops working, throws a error in model, when I add forward slash [/] . 但是,当我添加正斜杠[/]时,它将停止工作,并在模型中引发错误。 I can't understand why forward causes a problem. 我不明白为什么前进会引起问题。

I appreciate any help. 感谢您的帮助。

Thanks. 谢谢。

As stated in your other question, read about preg_match() patterns in the php manual. 如您在其他问题中所述,请阅读php手册中的preg_match()模式。 This function is used internally in the framework. 该函数在框架内部使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM