Ali*_*zad 2 regex laravel-5 laravel-validation
我想为字符串添加验证规则,以与正则表达式模式中提供的任何字符串完全匹配。例如,status必须完全是“已批准”或“待定”,不能有其他内容。
'status' => 'required|regex:[???]'
Run Code Online (Sandbox Code Playgroud)
您可以只使用in验证规则。
in:foo,bar,...正在验证的字段必须包含在给定的值列表中。
在你的情况下,这将是:
'status' => 'required|in:Approved,Pending'
Run Code Online (Sandbox Code Playgroud)