I try to add two differents messages for the same validator (required)
For example :
Do you have any suggestions ?
Currently its not supported to provide different messages for different fields, I will try to look into it tho.
I support this feature request - would love it to work as laravel does.
Thanks again for a great library!
I just added support for it, here is an example for it:
this.$validator.dictionary.merge({
en: {
custom: {
email: {
required: 'Your email is emoty'
},
name: {
required: () => 'Your name is empty'
}
}
}
})
You need to merge the custom messages object which contains keys of the fields names as properties, each property value is an object containing keys for each rule you would like to customize the message for. You only need to provide messages for the rules you would like to be replaced. It will fallback to the default messages included.
Also messages can be either strings or functions.
Note that you should merge the messages as soon as your app needs them, for example at the entry point or plugin installation.
This doesn't work for me
Do you have an example with html files
Thanks
It is not released yet, you can't use until the next RC release.
Most helpful comment
I just added support for it, here is an example for it:
You need to merge the custom messages object which contains keys of the fields names as properties, each property value is an object containing keys for each rule you would like to customize the message for. You only need to provide messages for the rules you would like to be replaced. It will fallback to the default messages included.
Also messages can be either strings or functions.
Note that you should merge the messages as soon as your app needs them, for example at the entry point or plugin installation.