
package com.github.britter.beanvalidators.net;

import com.github.britter.beanvalidators.net.internal.DomainConstraintValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
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.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Makes sure a string represents a valid domain.
 *
 * <p>Note that the list of valid top level domains is changes frequently. Since
 * this validator uses <a href="https://commons.apache.org/proper/commons-validator/apidocs/index.html">{@code org.apache.commons.validator.routines.DomainValidator}</a>
 * under the hood, there may be domains which
 * are actually valid reported as invalid, because the Apache Commons Validator TLP list is not up to date.</p>
 *
 * @since 0.3
 */
@Target({METHOD, FIELD, PARAMETER, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Constraint(validatedBy = DomainConstraintValidator.class)
@Documented
public @interface Domain {

    String message() default "{com.github.britter.beanvalidators.net.Domain.message}";

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

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

}
