Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Custom validator annotation
package sample;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Constraint(validatedBy = { SampleValidator.class })
public @interface SampleValidation {
String param() default "";
String message() default "Validation Error";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment