Pristine
Pristine copied to clipboard
Possible to globally set default messages for built-in validators?
Is it be possible to programmatically define a default message for one of the built-in validators, such as required? That is, rather than defaulting to This field is required, can that string be set globally, perhaps at initiation, to something else? (I know that I can do this though data-attributes, but adding a data-attribute to every input becomes tedious pretty quickly, and I'm not seeing an alternative in the docs.)
If this is not already possible, perhaps the config object passed to new Pristine() could also take an object of messages, with keys there defining each of the built-in validators' default messages?
let defaultConfig = {
classTo: 'form-group',
errorClass: 'has-danger',
successClass: 'has-success',
errorTextParent: 'form-group',
errorTextTag: 'div',
errorTextClass: 'text-help',
messages: {
required: '🙅 This field is required!',
email: 'Give us your email!',
{...}
}
};
@elseloop, there's a commit related to this in the feature/i18n branch. It'll be merged into master soon!
@sha256 any update on this item? I see the feature/il8n branch is still open but it looks like this feature may have been merged in but I don't see it in the docs.