javax.validation.constraints.PastOrPresent Maven / Gradle / Ivy
Show all versions of javaee-web-api Show documentation
/*
* Bean Validation API
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or .
*/
package javax.validation.constraints;
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;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.time.Year;
import javax.validation.ClockProvider;
import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.constraints.PastOrPresent.List;
/**
* The annotated element must be an instant, date or time in the past or in the present.
*
* Now is defined by the {@link ClockProvider} attached to the {@link Validator} or
* {@link ValidatorFactory}. The default {@code clockProvider} defines the current time
* according to the virtual machine, applying the current default time zone if needed.
*
* The notion of present is defined relatively to the type on which the constraint is
* used. For instance, if the constraint is on a {@link Year}, present would mean the whole
* current year.
*
* Supported types are:
*
* - {@code java.util.Date}
* - {@code java.util.Calendar}
* - {@code java.time.Instant}
* - {@code java.time.LocalDate}
* - {@code java.time.LocalDateTime}
* - {@code java.time.LocalTime}
* - {@code java.time.MonthDay}
* - {@code java.time.OffsetDateTime}
* - {@code java.time.OffsetTime}
* - {@code java.time.Year}
* - {@code java.time.YearMonth}
* - {@code java.time.ZonedDateTime}
* - {@code java.time.chrono.HijrahDate}
* - {@code java.time.chrono.JapaneseDate}
* - {@code java.time.chrono.MinguoDate}
* - {@code java.time.chrono.ThaiBuddhistDate}
*
*
* {@code null} elements are considered valid.
*
* @author Guillaume Smet
* @since 2.0
*/
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Repeatable(List.class)
@Documented
@Constraint(validatedBy = { })
public @interface PastOrPresent {
String message() default "{javax.validation.constraints.PastOrPresent.message}";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
/**
* Defines several {@link PastOrPresent} annotations on the same element.
*
* @see PastOrPresent
*/
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Documented
@interface List {
PastOrPresent[] value();
}
}