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

No validation performed with @Repeatable annotations used more than once for the same element #4831

Open
3 tasks done
racevedoo opened this issue Jan 21, 2021 · 1 comment
Labels
priority: medium Medium priority type: bug Something isn't working

Comments

@racevedoo
Copy link
Contributor

Hi guys, I'm having issues when using @Repeatable constraint annotations with micronaut-validation. When I add more than one of the same annotation to a field/class, no validation is performed. In other validation frameworks, like hibernate validator, they work normally. I created a minimal project that reproduces the issue in the tests: https://github.com/racevedoo/micronaut-validation-test

In this project, there are 2 objects that are validated, one contains a field with a single @Pattern constraint (PatternValidation), and other with multiple @Pattern constraints for the same field (PatternValidationMultipleAnnotations). I know the pattern annotation is not the best example, but for custom annotations it's quite common to annotate the same element multiple times with the same annotation (with different annotation parameters).

Is this a bug?

Task List

  • Steps to reproduce provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Run the following test

Expected Behaviour

The test should pass, as the object has constraint violations.

Actual Behaviour

The test does not pass, because no validation is performed.

Environment Information

  • Operating System: Linux Fedora 32
  • Micronaut Version: 2.2.3
  • JDK Version:
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode)

Example Application

https://github.com/racevedoo/micronaut-validation-test

@racevedoo
Copy link
Contributor Author

I did some digging of my own and found that Micronaut's DefaultValidator cannot find that the element is annotated with a @Constraint annotation, here.

This is probably due to the fact that the List annotation inside the standard javax.validation.constraints constraints does not contain the @Constraint annotation itself, it "delegates" to the inner annotation.

@graemerocher graemerocher added type: bug Something isn't working priority: medium Medium priority labels Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Medium priority type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants