-
Notifications
You must be signed in to change notification settings - Fork 92
Labels In Error Messages Instead of Property Names #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi |
For this particular use case, I'm using it client side for form validation. |
Workaround: use custom |
@icebob It's not a good solution, for example look at string rule messages:
You will probably have to customize a lot of these messages for a single field. schema = {
emailAddress: { type: "email", label: "Email Address" }
} |
I also think this would be a useful feature. You could have it default to the {field} unless you have provided the label. Rather than calling it eg. // elsewhere in code:
messages = { emailEmpty: "The '{path}' field must not be empty." }; schema = {
emailAddress: { type: "email" }
}
// would result in error: The 'emailAddress' field must not be empty. But if we provide the label schema = {
emailAddress: { type: "email", label: "Email Address" }
}
// would result in error: The 'Email Address' field must not be empty. |
We can't change the |
This is a must feature. Many coders use table column name, form field attribute name and schema property name same. So that dynamic communication of fields and errors are easy. This is the reason that this feature is available in yup also. Please implement it. This only keeps me from fastest-validator which is brilliant library no-doubt. |
Here is an example of current error message:
The 'email_address' field must not be empty.
Is there a way to pass field label into schema so the error message is displayed like so:
The 'Email Address' field must not be empty.
I know we can use custom messages for each field but curious if there's a lazier approach here :)
The text was updated successfully, but these errors were encountered: