1
|
package cz.zcu.kiv.backendapi.validation;
|
2
|
|
3
|
import javax.validation.Constraint;
|
4
|
import javax.validation.Payload;
|
5
|
import java.lang.annotation.*;
|
6
|
|
7
|
/**
|
8
|
* Constraint to email is valid
|
9
|
*/
|
10
|
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.ANNOTATION_TYPE})
|
11
|
@Retention(RetentionPolicy.RUNTIME)
|
12
|
@Constraint(validatedBy = EmailValidator.class)
|
13
|
@Documented
|
14
|
public @interface ValidEmail {
|
15
|
/**
|
16
|
* Error message when validation fails
|
17
|
*
|
18
|
* @return error message
|
19
|
*/
|
20
|
String message() default "Email is not valid - example \"x@x.xx\" (at least one character before and after \"@\" and two characters after \".\")";
|
21
|
|
22
|
Class<?>[] groups() default {};
|
23
|
|
24
|
Class<? extends Payload>[] payload() default {};
|
25
|
}
|