Question: Custom messages per rule and field
See original GitHub issueVersions:
- VueJs: 2.5.16
- Vee-Validate: 2.0.9
Assumptions
- Vue SSR
- I have an input component
- Scoped form
Question:
How would I do the following?
I’m trying to make the required
message for firstName
be:
Please enter your first name.
and for city
:
Please enter the city.
Steps To Reproduce:
So far I have:
const dictionary = {
en: {
messages: {
required: (field) => {
if (field === 'firstName') {
return `Please enter your ${field}.`
} else if (field === 'city') {
return `Please enter the ${field}.`
}
return `Please enter a ${field}.`
},
},
},
}
Object.keys(veeRules).forEach(k => Validator.extend(k, veeRules[k]))
Validator.localize('en', veeEn)
Vue.use(VeeValidate, { inject: false, dictionary })
But this doesn’t seem correct.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
CodeIgniter custom validation errors for each rule per each field
I'm using CodeIngiter 2.1 and I wanna define custom validation errors for each rule per each field. The fields are as follows. array(...
Read more >How to customize validate rule error messages | Support Center
When I enter numbers in the text field I get the error message "Enter a valid alphabetic value". I want to customize this...
Read more >How to have a custom message for any required fields
I have created custom object (School) with a custom field (Address) and checked it as required. Now the message is displayed as “Error:...
Read more >Response Requirements & Validation - Qualtrics
Custom validation is used when you need your respondent to answer a question in a specific way. For example, you may want them...
Read more >How to show custom error messages without using $validator?
You can't show validation errors for fields that aren't in the $rules. You set a custom message here for the participant_question field. Copy...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You could assign specific error messages to specific fields:
@elujoba I know that you fixed it, but more info is here: https://github.com/baianat/vee-validate/issues/1329