Skip to content

Request: ability to set error message per pattern #174

@mattpal

Description

@mattpal

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions