How to return custom validation messages using Illuminate\Validation\Rules\Password as password validation rules #46398
Unanswered
vitorbizarra
asked this question in
Q&A
Replies: 1 comment
-
I think you must should a method called messages() and put your messages, for example:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to return custom validation messages using Illuminate\Validation\Rules\Password as password validation rules
Introduction
Hi! I'm an Jr Developer from Brazil working on a self project that's an task manager, using Laraval as an API and VueJS as frontend.
Problem
The validation is working, the registration is not performed if the password does not comply with the validation rules, however, I would like to return customized messages to the user.
I added two methods in User model, one that return an array with the validation rules, and other that return the custom messages.
When one of the password validation rules is not fulfilled, it returns the error message of all the password validation rules, however, if the password is something like "FooBar#123", which complies with all the rules, the form validation is successfully performed and the account is registered.
It's not a problem that I would be urgent to solve because I'm working on other things within the project, but I would like to know how I can customize the return message for each password validation rule.
Before hand, thank you!
Here the code, the payload, and the response:
\App\Models\User.php
Submiting the form:
Payload:
Response:
Beta Was this translation helpful? Give feedback.
All reactions