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

Request: ability to set error message per pattern #174

Closed
mattpal opened this issue Sep 19, 2013 · 1 comment
Closed

Request: ability to set error message per pattern #174

mattpal opened this issue Sep 19, 2013 · 1 comment

Comments

@mattpal
Copy link

mattpal commented Sep 19, 2013

It looks like right now the default error message on a pattern uses the pattern name (key), but it would be nice to have a separate error message for a couple of reasons:

  • It's nice to have the keys short and with no spaces in them. My case was wanting to validate a domain name, so ideally i'd have:
    domainName = /some regex/
    I ended up with:
    'domain name' = /some regex/
    which is okay except for the next problem:
  • It's really hard to localize (impossible really) since the key is used in the error

I could write a custom validator for this, but even the built in patterns I'd have to either write custom validators for or change the message to a generic "Field is not in correct format" or something like that.

I could write an extended pattern validator to do what I need too, but it seems like it might be functionality that other people would want.

Other than that, I love the library!

@sagar-ganatra
Copy link

+1, I was about to log a request for allowing custom messages to be created for patterns.

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

2 participants