Annotation not applicable to type use with Java 8 in IntelliJ Idea
Answered
I am trying to use "@Email" validation annotation from "org.hibernate.validator.constraints" package, but I am getting a compilation error :- "@Email not applicable to type use"
Usage:-
List<@Email String> emailIds;
Environment:- Java 8, maven , IntelliJ (2016.1)
Please sign in to leave a comment.
So, does it build using Maven?
Here is the answer how you can validate a collection (each element inside a collection): http://stackoverflow.com/a/4329039/104891 .
BTW, why do you think that the problem is in IDEA?
Java 8 has introduced Type annotations, kindly refer to http://stackoverflow.com/a/31796895
@Email has the following @Target(value={METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER})
There is no TYPE.
Also this, https://dzone.com/articles/java-8-type-annotations
Can you build the project without errors outside of IDEA using Maven?
No. I believe this particular annotation does not support type as yet. Thanks for pointing this.