Skip to content
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

Possible to globally set default messages for built-in validators? #41

Open
elseloop opened this issue Oct 7, 2020 · 2 comments
Open

Comments

@elseloop
Copy link

elseloop commented Oct 7, 2020

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!',
       {...}
    }
};
@sha256
Copy link
Owner

sha256 commented Oct 10, 2020

@elseloop, there's a commit related to this in the feature/i18n branch. It'll be merged into master soon!

@misterhamm-bzs
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants