Laravel 验证规则列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47211686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:50:46  来源:igfitidea点击:

List of Laravel validation rules

laravelvalidationlaravel-5

提问by hightekjonathan

Is there a master list of all available rules for Laravel request validation? I have only seen the ones shown in the docs, but there must be more than just 4-5 rules. I know I can make custom ones, which I am currently, but I would like to know all of the available ones.

是否有 Laravel 请求验证的所有可用规则的​​主列表?我只看过文档中显示的那些,但肯定不止 4-5 条规则。我知道我可以制作定制的,我目前正在这样做,但我想知道所有可用的。

回答by Kenny Horna

There's a lot more than 4-5 validation rules. From the docs.

验证规则远不止 4-5 条。从文档

This is the current list (Laravel 7):

这是当前列表(Laravel 7):

Available Validation Rules

Below is a list of all available validation rules and their function:

Accepted

Active URL

After (Date)

After Or Equal (Date)

Alpha

Alpha Dash

Alpha Numeric

Array

Bail

Before (Date)

Before Or Equal (Date)

Between

Boolean

Confirmed

Date

Date Equals

Date Format

Different

Digits

Digits Between

Dimensions (Image Files)

Distinct

E-Mail

Ends With

Exists (Database)

File

Filled

Greater Than

Greater Than Or Equal

Image (File)

In

In Array

Integer

IP Address

JSON

Less Than

Less Than Or Equal

Max

MIME Types

MIME Type By File Extension

Min

Not In

Not Regex

Nullable

Numeric

Password

Present

Regular Expression

Required

Required If

Required Unless

Required With

Required With All

Required Without

Required Without All

Same

Size

Sometimes

Starts With

String

Timezone

Unique (Database)

URL

UUID

可用的验证规则

以下是所有可用验证规则及其功能的列表:

公认

活动网址

之后(日期)

之后或等于(日期)

Α

阿尔法短跑

字母数字

大批

保释

之前(日期)

之前或等于(日期)

之间

布尔值

确认的

日期

日期等于

日期格式

不同的

数字

数字之间

尺寸(图像文件)

清楚的

电子邮件

以。。结束

存在(数据库)

文件

填充

比...更棒

大于或等于

图像文件)

数组中

整数

IP地址

JSON

少于

小于或等于

最大限度

MIME 类型

MIME 类型按文件扩展名

最小

不在

不是正则表达式

可空

数字

密码

展示

正则表达式

必需的

如果需要

必需,除非

必填

所有人都需要

需要 没有

不需要全部

相同的

尺寸

有时

以。。开始

细绳

时区

唯一(数据库)

网址

用户名

回答by N Mahurin

If you check the Illuminate\Validation\Validator class it has quite a few arrays toward the top with different built in validation rules.

如果您检查 Illuminate\Validation\Validator 类,它的顶部有很多数组,具有不同的内置验证规则。

回答by user8865860

Laravel documentation enlists all the validators

Laravel 文档征集了所有验证器

https://laravel.com/docs/5.5/validation

https://laravel.com/docs/5.5/validation