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

Javax Validation Module: Validating Container Elements #60

Closed
TonyJulin opened this issue Mar 31, 2020 · 4 comments
Closed

Javax Validation Module: Validating Container Elements #60

TonyJulin opened this issue Mar 31, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@TonyJulin
Copy link

Hello. Great project so far. However, I've been running into an issue trying to apply container element constraints using the Javax validation module. For instance, I want to do something like: List<@Size(max=3) String> countryCodes but I can't get the result to appear in the schema output. Is there a configuration I need to do? Is it already an included feature? Thanks!

@CarstenWickner
Copy link
Member

Hi @TonyJulin,

That is currently not supported as I didn't yet look into how to access these annotations programmatically.

It should be possible according to this SO post.

However, I cannot promise when I will get to it right now.

@CarstenWickner
Copy link
Member

CarstenWickner commented Mar 31, 2020

Hi @TonyJulin,

I've made some changes to allow these container item annotations to be picked up – in #61.
However, there are some limitations – especially related to FasterXML/java-classmate#25.

I'm therefore not releasing this yet to first continue investigating what is necessary to access this kind of information through the classmate ResolvedType. Since that is the main type reference used throughout the configurations here, it would enable more advanced cases to be handled.

However, all the information I've used now is already available and you could re-create what I'm doing in the linked PR purely through configurations.

@TonyJulin
Copy link
Author

Thank you for quick response and follow-up post. Since this feature is only required on one field in one of our objects we're creating a schema for (so far) a small, hard-coded solution was sufficient. That being said, I'll take a look at the linked PR and will keep an eye on future versions in case it's added down the road.

@CarstenWickner
Copy link
Member

HI @TonyJulin,

Release v4.9.0 has just been published, including the support for at least the first-level container item annotations as per your given example.

  • List<@Size(max = 3) String> will be picked-up now
  • List<List<@Size(max = 3) String>> will not be picked-up

The change in the underlying classmate library is not so straightforward and I'm not sure when/if that will come out-of-the-box. Therefore releasing this basic/partial feature already which should cover the majority of use-cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants