Hellow fellow Artisan,
The date validation rule in Laravel checks {that a} subject is a legitimate date. Nevertheless, it doesn’t specify the format of the date. This could result in errors if the consumer enters the date in a distinct format than anticipated.
Instance if consumer enter incorrect date like this 20000-02-20 the place as a substitute of 4 digits(2000) for yr 5 digit(200000) set , it will trigger your utility to interrupt with this error under.
To keep away from your utility from break , you must keep away from utilizing solely date rule like 'merchandise.date_of_birth' => 'required|date|earlier than:' .in the present day()->subYears(7)->format('Y-m-d')
however you should use it with date_format() rule like this
'merchandise.date_of_birth' => 'required|date|date_format:Y-m-d|earlier than:' .in the present day()->subYears(7)->format('Y-m-d')
in order that as a substitute of your utility to interrupt, consumer will get the validation error.
Glad Coding !
Concerning the Writer
Hello there, I am a Full Stack Developer based mostly in Tanzania with a ardour for Laravel, Livewire, VueJs, TailwandCss, and internet growth. As a freelancer, I am all the time able to tackle thrilling tasks and collaborate on distant work associated to Laravel.
Should you’re searching for a devoted Laravel developer who may help you deliver your internet utility to life or improve your current Laravel mission, be at liberty to achieve out to me. I am wanting to work with you to create strong and revolutionary options for your enterprise wants.
You may contact me at [wazirially1994@gmail.com] or join with me at [https://github.com/WAZIRI123] and WhatsApp through:[+255653039317].
Let’s flip your Laravel mission into successful story collectively!