/*
* Jakarta Bean Validation API
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
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.FutureOrPresent.List;
The annotated element must be an instant, date or time in the present or in the future.
Now is defined by the ClockProvider
attached to the Validator
or ValidatorFactory
. The default clockProvider
defines the current time according to the virtual machine, applying the current default time zone if needed.
The notion of present here is defined relatively to the type on which the constraint is used. For instance, if the constraint is on a Year
, present would mean the whole current year.
Supported types are:
java.util.Date
java.util.Calendar
java.time.Instant
java.time.LocalDate
java.time.LocalDateTime
java.time.LocalTime
java.time.MonthDay
java.time.OffsetDateTime
java.time.OffsetTime
java.time.Year
java.time.YearMonth
java.time.ZonedDateTime
java.time.chrono.HijrahDate
java.time.chrono.JapaneseDate
java.time.chrono.MinguoDate
java.time.chrono.ThaiBuddhistDate
null
elements are considered valid.
Author: Guillaume Smet Since: 2.0
/**
* The annotated element must be an instant, date or time in the present or in the future.
* <p>
* <i>Now</i> 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.
* <p>
* The notion of present here 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.
* <p>
* Supported types are:
* <ul>
* <li>{@code java.util.Date}</li>
* <li>{@code java.util.Calendar}</li>
* <li>{@code java.time.Instant}</li>
* <li>{@code java.time.LocalDate}</li>
* <li>{@code java.time.LocalDateTime}</li>
* <li>{@code java.time.LocalTime}</li>
* <li>{@code java.time.MonthDay}</li>
* <li>{@code java.time.OffsetDateTime}</li>
* <li>{@code java.time.OffsetTime}</li>
* <li>{@code java.time.Year}</li>
* <li>{@code java.time.YearMonth}</li>
* <li>{@code java.time.ZonedDateTime}</li>
* <li>{@code java.time.chrono.HijrahDate}</li>
* <li>{@code java.time.chrono.JapaneseDate}</li>
* <li>{@code java.time.chrono.MinguoDate}</li>
* <li>{@code java.time.chrono.ThaiBuddhistDate}</li>
* </ul>
* <p>
* {@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 FutureOrPresent {
String message() default "{javax.validation.constraints.FutureOrPresent.message}";
Class<?>[] groups() default { };
Class<? extends Payload>[] payload() default { };
Defines several FutureOrPresent
annotations on the same element. See Also:
/**
* Defines several {@link FutureOrPresent} annotations on the same element.
*
* @see FutureOrPresent
*/
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Documented
@interface List {
FutureOrPresent[] value();
}
}