Format date before validation
This is how I validate some inputs:
$request->validate([
'holidaydate' => 'required|unique:holidays,holidaydate,NULL',
'description' => 'required'
]);
Is there a way to format holidaydatebefore I validate it?
If you are using Request objects (php artisan make:request) then you can use following:
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
//
}
Try adding this before the validation line:
$request->merge(['holidaydate' => Carbon::createFromFormat('d/m/Y', $request->input('holidaydate'))->format('m-d-Y')]);
I gave just an example, I don't know the expected format.
Please or to participate in this conversation.