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

Default validators #25

Closed
danielgratzl opened this issue Aug 7, 2014 · 3 comments
Closed

Default validators #25

danielgratzl opened this issue Aug 7, 2014 · 3 comments

Comments

@danielgratzl
Copy link

Are there any plans to add implementations for default validation tasks like email, etc or will this be left to the user? if so, whats the best way to create custom validators?
I ended up writing custom lots of custom validators anyway because i didn't find another way to change the validation failed messages.

These often look like

  class ValidGender()
    extends NullSafeValidator[ String ]( Set("m", "f", "u").contains(_), _ -> s"must be a valid gender [m ,f, u]" )

  def validGender: WixValidator[ String ] = new ValidGender()
@holograph
Copy link
Contributor

This looks like a very solid custom validator (with the possible exception that you can simply use an object instead of instantiating a stateless class).

Per your original question, I'm basically collecting sensible use cases of what to end to the library. E-mail might be a good use case, do you have any others?

@danielgratzl
Copy link
Author

I came to the conclusion that it's probably not really a good idea to include concrete implementations of domain validators to this library.

The email use case is a good example for why not. There are solid implementations of email validators which can and imho should be reused (http://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/package-summary.html#other.email for example) but it doesn't make much sense to bundle these with accord.

For me accord does a great job what would make it even better if we had the possibility to customize the violation messages and maybe even types as already stated in the roadmap

@holograph
Copy link
Contributor

Indeed :-) That's probably my next project (the current one being #6).

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

No branches or pull requests

2 participants