You miss underscore.
'birth_date' => 'required|date_format:YYYY-MM-DD',
Docs: https://laravel.com/docs/8.x/validation#rule-date-format
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have created the import class using model with validation rules. I need to validate the date format for date column as YYYY-MM-DD. The below rules validation is not working. Kindly clarify how to achieve this?
class StudentImport implements ToModel, WithHeadingRow, WithValidation, SkipsOnFailure
{
use Importable, SkipsFailures;
public function rules(): array
{
return [
'email' => 'string|email|max:255|exists:users',
'birth_date' => 'required|dateformat:YYYY-MM-DD',
];
}
public function onFailure(Failure ...$failures)
{
// Handle the failures how you'd like.
}
public function model(array $row)
{
//Handle the import code here
}
}
The below rules validation is not working.
How do I achieve this?
Please or to participate in this conversation.