0

I creating a custom validation rule in my cakephp model.

        '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.

2
  • 2
    Adding a slash to the validation rule leads to the error? Or having a slash in the input field? Also, can you post the error itself? Commented Mar 14, 2011 at 13:46
  • iirc it has special meaning for regex, see my answer. Commented Mar 14, 2011 at 14:12

1 Answer 1

1

As stated in your other question, read about preg_match() patterns in the php manual. This function is used internally in the framework.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.