adspace


How do I customize validation error messages for a form?

Answer Posted / Neeraj Semwal

To customize validation error messages in Laravel, you can use the `validate()` method with an instance of the `Validator` class. Here's an example:nn```phpnpublic function store(Request $request) {n $validatedData = $this->validate($request, [ // Your validation rules heren]);n}nn// app/Validation/Rules/CustomRule.phpnclass CustomRule extends Rule {n protected $message = 'This field is required and must be a valid number between 10 and 20.';nn public function passes($attribute, $value) {n return (is_numeric($value)) && ($value >= 10 && $value <= 20);n }n}n```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell us have you used lumen before?

809


What is current stable version of laravel?

870


What is latest version of laravel?

869


Do you know what version of laravel do you generally use?

839


How much laravel experience do you have?

815