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

Use Bean Validation metadata API for constraint retrieval #33

Open
gunnarmorling opened this issue Mar 16, 2017 · 2 comments
Open

Use Bean Validation metadata API for constraint retrieval #33

gunnarmorling opened this issue Mar 16, 2017 · 2 comments

Comments

@gunnarmorling
Copy link

gunnarmorling commented Mar 16, 2017

Hi, I just came across this library; nice stuff!

Exposing constraint metadata so it is consumable also from non-Java clients has been one goal of Bean Validation from day one. We actually provide an API for obtaining all the constraints from given model classes: http://beanvalidation.org/1.1/spec/#constraintmetadata.

I would suggest to use that API instead of doing your own annotation scanning. It would then not matter how constraints are declared (annotations vs. XML vs. HV's programmatic API), whether constraints are given on fields vs. getters, it resolves default validation messages, it deals with constraint composition etc.

I.e. we already do all the hard work for you :)

@marcelstoer
Copy link
Collaborator

marcelstoer commented Mar 16, 2017

I just came across this library

Not really, is it? You reached out to me by email in June 2016 😄

We actually provide an API for obtaining all the constraints from given model classes: http://beanvalidation.org/1.1/spec/#constraintmetadata.

Thanks for pushing Gunnar, you mentioned that in the email 😉 So, I've known for about nine months that there's room for improvement here. It's good that there's now a publicly visible issue for that.

@gunnarmorling
Copy link
Author

Hi Marcel, uh oh, it had completely escaped my mind that we've been in touch before 😃 Using the meta-data API would be great; I noticed because it would return the default message key ("{javax.validation.constraints.NotNull.message}") instead of the value from the default message bundle.

I've filed netceteragroup/valdr#119 for the message interpolation issue.

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