
/*
 * Copyright (C) 2011 Archie L. Cobbs. All rights reserved.
 *
 * $Id$
 */

package org.dellroad.stuff.validation;

import java.lang.annotation.Documented;
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;
import javax.validation.ReportAsSingleViolation;
import javax.validation.constraints.Pattern;

/**
 * Validation constraint requiring a {@link String} to be a valid email address.
 */
@Documented
@Constraint(validatedBy = {})
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Pattern(regexp = "^[-+._\\p{Alnum}]+@[-\\p{Alnum}]+(\\.[-.\\p{Alnum}]+)+$")
@ReportAsSingleViolation
public @interface EmailAddress {

    String message() default "Invalid email address";

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

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


@@ -748,65 +748,28 @@
 p = 
-%22%5E%5B-+._%5C%5Cp%7BAlnum%7D%5D+@%5B-%5C%5Cp%7BAlnum%7D%5D+(%5C%5C.%5B-.%5C%5Cp%7BAlnum%7D%5D+)+$%22
+EmailAddress.PATTERN
 )%0A@R
@@ -825,16 +825,212 @@
 ress %7B%0A%0A
+    /**%0A     * The regular expression string used by this constraint to validate email addresses: %7B@value%7D%0A     */%0A    String PATTERN = %22%5E%5B-+%25._%5C%5Cp%7BAlnum%7D%5D+@(%5B-%5C%5Cp%7BAlnum%7D%5D+%5C%5C.)+%5B-%5C%5Cp%7BAlnum%7D%5D+$%22;%0A%0A
     Stri

Tweak email address pattern and define the string as a constant.