Issue with Laravel Rules & Regex (OR) operator

前端 未结 3 1479
悲哀的现实
悲哀的现实 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:14

    http://laravel.com/docs/validation#rule-regex

    regex:pattern

    The field under validation must match the given regular expression.

    Note: When using the regex pattern, it may be necessary to specify rules in an array instead >of using pipe delimiters, especially if the regular expression contains a pipe character.

    To clarify: You would do something like this

    $rules = array('test' => array('size:5', 'regex:foo'));
    

提交回复
热议问题