Open dangelion opened 9 years ago
If you want to customize the messages of your own pattern, you should do it in the pattern itself, like:
_.extend(Backbone.Validation.messages, {
myPattern: 'This is an error message'
});
Keep this in mind:
The validator should return an error message when the value is invalid, and nothing (undefined) if the value is valid.
Hi @chiefGui there is no way to override message for my patterns outside them? I'd like to manage all the messages in the same place, among the default ones
Do you want this, right?
_.extend(Backbone.Validation.messages, {
required: '{0} is required',
myPattern: 'This is an error message'
});
So, you already did this. What's going on? What's the error?
You said:
myPattern: 'my text here' // <=== This doesn't work
But, what's happening?
It returns the message specified inside the custom validator instead of the one specified in the _.extend
Here is explained how to override messages: https://github.com/thedersen/backbone.validation#overriding-the-default-error-messages
how can specify the message for specific patterns (like "email")?
EDIT: found solution for pattern "email" (you could add it to docs)
but what about a custom validator (myPattern)?
I want to override that cause I want to handle all messages in the same place.