是否有用于Laravel请求验证的所有可用规则的主列表?我只看过文档中显示的内容,但必须有超过4-5条的规则。我知道我可以做定制的,这是我目前,但我想知道所有可用的。
发布于 2017-11-09 21:35:05
有很多超过4-5的验证规则。来自文档。
这是目前的清单(Laravel 9):
已接受 接受如果 活动URL (日期)之后 之后或相等(日期) Alpha 阿尔法达什 阿尔法数字 数组 保释金 在(日期)之前 之前或相等(日期) 在两者之间 布尔值 已确认 当前密码 日期 日期等于 日期格式 谢绝 谢绝 不同 位数 间位数 维度(图像文件) 分异 一开始并不是 不止于此 电子邮件 尾声 枚举 排除 排除如果 排除,除非 排除与 不排除 存在(数据库) 文件 填满 大于 大于或等于 图像(档案) 在……里面 内阵列 整数 IP地址 JSON 少于 小于或等于 MAC地址 最大值 MIME类型 MIME文件扩展名类型 最小 倍数 不在 不是Regex 可空 数字 密码 现在时 禁止 禁止下列情况 禁止,除非 禁止 正则表达式 必填项 所需条件 规定,除非 要求与 需要与所有 不需要 不需要全部 所需阵列键 相同的 大小 有时 一开始 字符串 时区 唯一(数据库) URL UUID
发布于 2017-11-09 21:26:32
如果您检查照明\验证\Validator类,它有相当多的数组指向顶部,具有不同的内置验证规则。
发布于 2020-11-17 19:10:51
我不知道其他人是否会觉得这个有用,但是您可以使用反射来找出验证器:
$validatorClass = new ReflectionClass(Illuminate\Validation\Concerns\ValidatesAttributes::class);
collect($validatorClass->getMethods(ReflectionMethod::IS_PUBLIC))
->filter(function($method){
return Illuminate\Support\Str::startsWith($method->name,'validate');
})
->map(function($method){
return str_replace('validate_', '', Illuminate\Support\Str::snake($method->name));
})
->dd();
array:68 [
0 => "accepted"
1 => "active_url"
2 => "bail"
3 => "before"
4 => "before_or_equal"
5 => "after"
6 => "after_or_equal"
7 => "alpha"
8 => "alpha_dash"
9 => "alpha_num"
10 => "array"
11 => "between"
12 => "boolean"
13 => "confirmed"
14 => "date"
15 => "date_format"
16 => "date_equals"
17 => "different"
18 => "digits"
19 => "digits_between"
20 => "dimensions"
21 => "distinct"
22 => "email"
23 => "exists"
24 => "unique"
28 => "file"
29 => "filled"
30 => "gt"
31 => "lt"
32 => "gte"
33 => "lte"
34 => "image"
35 => "in"
36 => "in_array"
37 => "integer"
38 => "ip"
39 => "ipv4"
40 => "ipv6"
41 => "json"
42 => "max"
43 => "mimes"
44 => "mimetypes"
45 => "min"
46 => "nullable"
47 => "not_in"
48 => "numeric"
49 => "present"
50 => "regex"
51 => "not_regex"
52 => "required"
53 => "required_if"
54 => "exclude_if"
55 => "exclude_unless"
56 => "exclude_without"
57 => "required_unless"
58 => "required_with"
59 => "required_with_all"
60 => "required_without"
61 => "required_without_all"
62 => "same"
63 => "size"
64 => "sometimes"
65 => "starts_with"
66 => "ends_with"
67 => "string"
68 => "timezone"
69 => "url"
70 => "uuid"
]https://stackoverflow.com/questions/47211686
复制相似问题