Custom validation error messages

20 0 0 0

Last Updated : 2020-10-20 20:29:07

In case you wanetd to change the error message of a validation rule in Laravel you can make use of the following snippet.

$messages = [
'fullTextPDF.mimes' => 'only PDF files are allowed.',

$validator = Validator::make($request->all(), [
'bill_id' => 'required',
'fullTextPDF' => 'mimes:pdf',
], $messages);

$errors = $validator->errors();

Mohammed Anwar

Mohammed Anwar

Experienced technical lead PHP, MySQL and Laravel Developer for 15+ years, with proven ability to develop and create high-quality and optimized web applications. Great ability to build and optimize database design, schema and queries. Versed programing trainer and instructor delivering web courses and helping others to get into the field in a timely manner. Fast and eager learner for new technologies .