2

我想为字符串添加一个验证规则,以完全匹配正则表达式模式中提供的任何字符串。例如,status必须完全是“已批准”或“待定”,仅此而已。

'status' => 'required|regex:[???]'
4

1 回答 1

4

You can just use the in validation rule.

in:foo,bar,...

The field under validation must be included in the given list of values.

In your case that would be:

'status' => 'required|in:Approved,Pending'
于 2015-03-09T09:26:46.480 回答