php - 数字的 Laravel 规则验证

标签 php laravel laravel-4

我有以下规则:

'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/

相关文章:

javascript - 我需要我的 javascript 代码来通过代码块检索 id

php - Laravel 4 中 Input::flash() 和 Session::flash() 的区别

php - 了解编程安全相关主题的最佳方式是什么? (PHP)

php - 为什么在面向对象的 PHP 中不推荐直接访问属性?

Laravel 从嵌套关系中提取一个数组

php - Laravel - 调用未定义的方法 Illuminate\Foundation\Application::share()

laravel - Eloquent ORM中的自然订单,Laravel 4

php - hasManyThrough关系返回错误的SQL语句

php - 友好的 URL 和 htaccess 级别

php - 这个switch语句不是废话吗?