You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: validation.md
+59Lines changed: 59 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1062,11 +1062,36 @@ Instead of passing a date string to be evaluated by `strtotime`, you may specify
1062
1062
1063
1063
'finish_date' => 'required|date|after:start_date'
1064
1064
1065
+
For convenience, date based rules may be constructed using the fluent `date` rule builder:
1066
+
1067
+
use Illuminate\Validation\Rule;
1068
+
1069
+
'start_date' => [
1070
+
'required',
1071
+
Rule::date()->after(today()->addDays(7)),
1072
+
],
1073
+
1074
+
The `afterToday` and `todayOrAfter` methods may be used to fluently express the date must be after today or or today or after, respectively:
1075
+
1076
+
'start_date' => [
1077
+
'required',
1078
+
Rule::date()->afterToday(),
1079
+
],
1080
+
1065
1081
<aname="rule-after-or-equal"></a>
1066
1082
#### after\_or\_equal:_date_
1067
1083
1068
1084
The field under validation must be a value after or equal to the given date. For more information, see the [after](#rule-after) rule.
1069
1085
1086
+
For convenience, date based rules may be constructed using the fluent `date` rule builder:
1087
+
1088
+
use Illuminate\Validation\Rule;
1089
+
1090
+
'start_date' => [
1091
+
'required',
1092
+
Rule::date()->afterOrEqual(today()->addDays(7)),
1093
+
],
1094
+
1070
1095
<aname="rule-alpha"></a>
1071
1096
#### alpha
1072
1097
@@ -1144,11 +1169,36 @@ While the `bail` rule will only stop validating a specific field when it encount
1144
1169
1145
1170
The field under validation must be a value preceding the given date. The dates will be passed into the PHP `strtotime` function in order to be converted into a valid `DateTime` instance. In addition, like the [`after`](#rule-after) rule, the name of another field under validation may be supplied as the value of `date`.
1146
1171
1172
+
For convenience, date based rules may also be constructed using the fluent `date` rule builder:
1173
+
1174
+
use Illuminate\Validation\Rule;
1175
+
1176
+
'start_date' => [
1177
+
'required',
1178
+
Rule::date()->before(today()->subDays(7)),
1179
+
],
1180
+
1181
+
The `beforeToday` and `todayOrBefore` methods may be used to fluently express the date must be before today or or today or before, respectively:
1182
+
1183
+
'start_date' => [
1184
+
'required',
1185
+
Rule::date()->beforeToday(),
1186
+
],
1187
+
1147
1188
<aname="rule-before-or-equal"></a>
1148
1189
#### before\_or\_equal:_date_
1149
1190
1150
1191
The field under validation must be a value preceding or equal to the given date. The dates will be passed into the PHP `strtotime` function in order to be converted into a valid `DateTime` instance. In addition, like the [`after`](#rule-after) rule, the name of another field under validation may be supplied as the value of `date`.
1151
1192
1193
+
For convenience, date based rules may also be constructed using the fluent `date` rule builder:
1194
+
1195
+
use Illuminate\Validation\Rule;
1196
+
1197
+
'start_date' => [
1198
+
'required',
1199
+
Rule::date()->beforeOrEqual(today()->subDays(7)),
1200
+
],
1201
+
1152
1202
<aname="rule-between"></a>
1153
1203
#### between:_min_,_max_
1154
1204
@@ -1193,6 +1243,15 @@ The field under validation must be equal to the given date. The dates will be pa
1193
1243
1194
1244
The field under validation must match one of the given _formats_. You should use **either**`date` or `date_format` when validating a field, not both. This validation rule supports all formats supported by PHP's [DateTime](https://www.php.net/manual/en/class.datetime.php) class.
1195
1245
1246
+
For convenience, date based rules may be constructed using the fluent `date` rule builder:
0 commit comments