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.
Each form request generated by Laravel has two methods: authorize and rules .
php", to replace the :attribute name (input name) for a proper to read name (example: first_name > First name) . It seems very simple to use, but the validator doesn't show the "nice names". And the validation in the controller: $validation = Validator::make($input, $rules, $messages);
There's a lot more than 4-5 validation rules. From the docs.
This is the current list (Laravel 8):
Accepted
Active URL
After (Date)
Alpha
Alpha Dash
Array
Bail
Before (Date)
Between
Boolean
Confirmed
Date
Different
Digits
Distinct
Ends With
Exclude If
File
Filled
Greater Than
Image (File)
In
In Array
Integer
IP Address
JSON
Less Than
Less Than Or Equal
Max
MIME Types
Min
Multiple Of
Not In
Not Regex
Nullable
Numeric
Password
Present
Prohibited
Required
Same
Size
Sometimes
String
Timezone
URL
UUID
I don't know if anyone else will find this useful, but you can use reflection to figure out the validators:
$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"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With