package stroom.util.shared.validation;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.NotNull;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target({ FIELD, METHOD, PARAMETER, ANNOTATION_TYPE, TYPE_USE })
@Retention(RUNTIME)
@Constraint(validatedBy = {ValidRegexValidator.class})
@Documented
public @interface ValidRegex {

    String message() default "regex pattern is invalid";

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

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

    // Allows for multiple annotations on the same element
    @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
    @Retention(RUNTIME)
    @Documented
    @interface List {
        NotNull[] value();
    }
}

@@ -672,16 +672,148 @@
 NTIME;%0A%0A
+/**%0A * Validation to ensure that the annotated value is a valid regex pattern%0A * conforming to %7B@link java.util.regex.Pattern%7D.%0A */%0A
 @Target(

Add Javadoc