开发者

Problem setting custom validation rules in Cakephp

开发者 https://www.devze.com 2023-02-16 21:35 出处:网络
I creating a custom validation rule in my cakephp model. 开发者_C百科\'article\' => array( \'rule\' => \'/^[a-z0-9#.,&; ]{2,255}$/i\',

I creating a custom validation rule in my cakephp model.

        开发者_C百科'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. This function is used internally in the framework.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号