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

Expand @Target to method and constructor arguments #11

Open
kozlovda opened this issue Feb 24, 2015 · 3 comments
Open

Expand @Target to method and constructor arguments #11

kozlovda opened this issue Feb 24, 2015 · 3 comments

Comments

@kozlovda
Copy link

Hi Jakob,

Nice set of handy validators, thanks! (and shame on http://beanvalidation.org to not support them out of the box though).

But I'm curious if it's possible to extend annotations' target to method params and constructor arguments as well?

E.g. for @Size annotation:

  • original annotation:
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = { })
public @interface Size {
  • each-annotation:
@Documented
@Retention(RUNTIME)
@Target({METHOD, FIELD, ANNOTATION_TYPE})
@EachConstraint(validateAs = Size.class)
@Constraint(validatedBy = CommonEachValidator.class)
public @interface EachSize {

Having taken a quick look through the code I'd guess it should be as easy as to add those two target enum values.

Otherwise it appears to be pretty useless in a typical situation when you need to annotate multi-value query param in JAX-RS resource method definition, like this:

@Path("/")
public interface MyResource {

   @Path("/by-tags")
   List<MyDto> searchByTags(@QueryParam("tag") @EachSize(min = 2, max = 127) Set<String> tags);

}
@fgaule
Copy link

fgaule commented Mar 7, 2015

+1

@Blackbaud-RyanMcKay
Copy link

I would like this too, is there any argument with this suggestion, or does somebody just need to send a PR?

@oburgosm
Copy link

+1

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

5 participants