Home / Snippets / How to Customize validation error messages in Laravel?
How to Customize validation error messages in Laravel? cover

How to Customize validation error messages in Laravel?

411

3 years ago

0 comments

Laravel provides default error messages that are sufficient enough for most validation scenarios. In addition to that default one, you can add a custom validation error messages that you can define within the "resources/lang/[language]/validation.php" file.
resources/lang/[language]/validation.php

The validation errors can be defined in a key-value pair manner but you have to provide the appropriate structure in order for it to work.

Below is an example of how you can define the error validation message.
<?php # resources/lang/en/validation.php

return [
    'custom' => [
        'email' => [
            'required' => 'We need to know your email address!',
            'max' => 'Your email address is too long!'
        ],
    ],
],
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this