$DOB = $request->input('DOB');
$allowed = Carbon::now()->subYears(26)->format('Y-m-d');
$validatedData = $request->validate(
['DOB' => 'required|date|before_or_equal:'.$allowed],
);
<input type="date" name="DOB" class="form-control" required>
I am having a hard time validating dates in Laravel.
If I enter 01/01/2018 in the form, the validation does not catch it. Below it what is returned if I dd() the variables.
dd([$DOB, $allowed]);
array:2 [▼
0 => "2018-01-01"
1 => "1992-04-26"
]
No idea where I am going wrong.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire