Hi,
I am parsing data from an excel file import, and putting them in variables. The validation for a date is not triggering the error. This is the parsing code I have:
'date_of_application' => Carbon::parse($value->date_of_application)->format('Y-m-d');
The problem is that, if I give some false value (e.g. 01/01/0019), Carbon parsing does not throw an error, but instead it puts the value of today in the variable. I have few checks ahead in the code, but they are never triggered since Carbon already replaces the date with the current date.
Please note that in excel import, 01/01/2019 is an acceptable format which Carbon parses as 2019-01-01 successfully. It just looks like 01/01/2019 when opened in excel. So the format is not the issue.
Any good way to handle this? Ideally, Carbon should throw error on encountering 0019 as year... Or at least not replace it with today's date if 0019 is a valid programming date.
Thanks,
Saad