我有以下规则:
'Fno' => 'digits:10'
'Lno' => 'min:2|max5' // this seems invalid
但是如何有规则
Fno 应该是一个最少 2 位到最多 5 位的数字,并且
Lno 应该是一个数字,最少 2 位数字
最佳答案
如果我正确地得到了你想要的:
$rules = ['Fno' => 'digits_between:2,5', 'Lno' => 'numeric|min:2'];
或
$rules = ['Fno' => 'numeric|min:2|max:5', 'Lno' => 'numeric|min:2'];
对于所有可用规则:http://laravel.com/docs/4.2/validation#available-validation-rules
digits_between :min,max
The field under validation must have a length between the given min and max.
numeric
The field under validation must have a numeric value.
max:value
The field under validation must be less than or equal to a maximum value. Strings, numerics, and files are evaluated in the same fashion as the size rule.
min:value
The field under validation must have a minimum value. Strings, numerics, and files are evaluated in the same fashion as the size rule.
关于php - 数字的 Laravel 规则验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27614936/