John Davidson

php - laravel change validation default message from front side

0 comments
Message:


Laravel change validation default message



  • change validation message from front side

  • read validation.php file and than write that file from front side


is it possible ?



My Answer:
Yes, it is possible to change the validation default message from the front side in Laravel. You can achieve this by reading the `validation.php` file and then overriding the default messages from the front end.

Here is an example of how you can do this:

1. Read the `validation.php` file from the front end:

php
$validationMessages = require('resources/lang/en/validation.php');


2. Override the default messages with your custom messages:

php
$validationMessages['custom']['email'] = [
'required' => 'The email field is required.',
'email' => 'Please enter a valid email address.',
];

// Add more custom messages as needed


3. Use the `Validator` facade to set the custom messages:

php
Validator::setCustomMessages($validationMessages);


By following these steps, you can change the validation default message from the front end in Laravel.

Rate this post

3 of 5 based on 6022 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us