Issue with Laravel Rules & Regex (OR) operator

前端 未结 3 1477
悲哀的现实
悲哀的现实 2020-11-28 15:34

I\'m having a small issue with my Laravel rules and regex operation :

Basically a rule is an array as such :

\'room\'=>\'required|alpha_num|min:2|         


        
3条回答
  •  青春惊慌失措
    2020-11-28 16:33

    You should use an array instead of separating rules using |:

    'cid' => array('required', 'regex:/^((comp)|(soen)|(engr)|(elec))\d{3}$/i')
    

    The pipe (|) sigh is available in your regular expression pattern so it's conflicting with the separator. Other answer already stated it.

提交回复
热议问题