I'm on Laravel 4.2 and want to validate a date from a text field. My issue is that I use the rule date_format:Y-m-d H:i:s for validating the date format. But I also want to accept 0000-00-00 00:00:00 when the user enter nothing. Of course this is not a valid date so I don't know how to handle that... Any ideas ?
Yes I validate it, but not require it. Regex can do the trick but I loose the date validation. There is no way to add like an except rule for validation ?
But doing "date_format:d/m/Y" will and up blocking the date as well because when sending 0000-00-00 00:00:00 or 00/00/0000 in your case it's not a valid date, it should be minimum of 01/01/0001...
That's what I do right now. But I was wanting to display 0000-00-00 00:00:00 when nothing is enter so the user understand. But doing that the post is not empty so the validation is done on this value and failes.
There are differents dates. One for example is for a filter for date range, so I have From and To and need a valid date format but also accept 0000-00-00 when the user chosse nothing.