Reputation: 9890
I am trying to validate a date in Laravel. I am using datepicker
in the frontend where the JavaScript sends the date to the server Laravel in this format dd-MMMM-yy
:
$scope.formData.dob = $filter('date')(scope.formData.dob, 'dd-MMMM-yy');
My laravel has a validation like this:
$validator = Validator::make($postData, [
'dob' => 'date_format:"dd-MMMM-yy"',
]);
However the validator keeps saying that the date does not match the format dd-MMMM-yy
:
The dob does not match the format dd-MMMM-yy.
I thought maybe it has to do with the format type so I tried changing it to different formats like d/m/y, dd-mm-yyyy, etc.. in both JavaScript date and Laravel date validation but everything keeps saying the same error that the date doesn't match. The output seems fine though and it is in the format I have mentioned in validation. I dont understand why Laravel validation fails.
Am I missing something here?
Upvotes: 0
Views: 6199