Close

JavaBean Validation - validationAppliesTo Examples

JavaBean Validation JAVA EE 

import javax.validation.Constraint;
import javax.validation.ConstraintTarget;
import javax.validation.Payload;
import java.lang.annotation.*;

@Documented
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {EvenNumbersInputValidator.class, EvenNumbersOutputValidator.class})
@Repeatable(EvenNumbers.List.class)
public @interface EvenNumbers {

String message() default "not valid even numbers: ${validatedValue}";

Class<?>[] groups() default {};

Class<? extends Payload>[] payload() default {};

ConstraintTarget validationAppliesTo() default ConstraintTarget.IMPLICIT;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface List {
EvenNumbers[] value();
}
}
Original Post




See Also