Validation Message needs to refactor
I am using FileUpload method from the #filament, but getting this weird error message, I had applied Handler, getValidationAttributes() & getValidationMessages(), but none of them is working. Can someone help me to resolve this one?
#laravel V11.31 #filament V3.2 #livewire V3.0
// custom messages
protected function getValidationAttributes(): array
{
return [
'data.liens..lien_documents.' => 'Lien Document'
];
}
protected function getValidationMessages(): array
{
$allowed = 'PDF, Word (doc/docx), Excel (xls/xlsx), CSV, image (jpg/png/gif/bmp/tiff), or ZIP';
return [
// file type (mimes) messages
'data.liens..lien_documents..mimes' => "The :attribute must be one of: {$allowed}.",
// generic file validation
'data.liens..lien_documents..file' => 'The :attribute must be a valid file.',
// size limits
'data.liens..lien_documents..max' => 'The :attribute must not be larger than :max kilobytes.',
];
}


1 Reply
This is a Laravel validation message. You need to publish laravel language file for validation and than change the
mimes field. Or you need to catch the ValidationException someway and throw your own validation exception withMessages(...).
https://github.com/laravel/framework/blob/12.x/src%2FIlluminate%2FTranslation%2Flang%2Fen%2Fvalidation.php#L105GitHub
framework/src/Illuminate/Translation/lang/en/validation.php at 12.x...
The Laravel Framework. Contribute to laravel/framework development by creating an account on GitHub.