javax.validation.constraints.FutureOrPresent Java Examples
The following examples show how to use
javax.validation.constraints.FutureOrPresent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultModelPlugin.java From BlogManagePlatform with Apache License 2.0 | 6 votes |
private String resolveDate(Field field) { Future future = field.getAnnotation(Future.class); if (future != null) { return "必须为未来的时间"; } FutureOrPresent futureOrPresent = field.getAnnotation(FutureOrPresent.class); if (futureOrPresent != null) { return "必须为未来或现在的时间"; } Past past = field.getAnnotation(Past.class); if (past != null) { return "必须为过去的时间"; } PastOrPresent pastOrPresent = field.getAnnotation(PastOrPresent.class); if (pastOrPresent != null) { return "必须为过去或现在的时间"; } return null; }
Example #2
Source File: BeanValidationImpl.java From cuba with Apache License 2.0 | 6 votes |
protected HibernateValidatorConfiguration getValidatorFactoryConfiguration(Locale locale) { HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class) .configure() .clockProvider(new CubaValidationTimeProvider(timeSource)) .traversableResolver(new CubaValidationTraversableResolver(metadata, entityStates)) .messageInterpolator(new CubaValidationMessagesInterpolator(messages, locale)); ConstraintMapping constraintMapping = configuration.createConstraintMapping(); //Hibernate validators doesn't support java.sql.Date. //Replace standard validators for java.util.Date with support java.sql.Date registerPastValidators(constraintMapping.constraintDefinition(Past.class)); registerPastOrPresentValidators(constraintMapping.constraintDefinition(PastOrPresent.class)); registerFutureValidators(constraintMapping.constraintDefinition(Future.class)); registerFutureOrPresentValidators(constraintMapping.constraintDefinition(FutureOrPresent.class)); configuration.addMapping(constraintMapping); return configuration; }
Example #3
Source File: BeanValidationImpl.java From cuba with Apache License 2.0 | 6 votes |
protected void registerFutureOrPresentValidators(ConstraintDefinitionContext<FutureOrPresent> context) { context.includeExistingValidators(false) .validatedBy(FutureOrPresentValidatorForCalendar.class) .validatedBy(CubaFutureOrPresentValidatorForDate.class) // Java 8 date/time API validators .validatedBy(FutureOrPresentValidatorForHijrahDate.class) .validatedBy(FutureOrPresentValidatorForInstant.class) .validatedBy(FutureOrPresentValidatorForJapaneseDate.class) .validatedBy(FutureOrPresentValidatorForLocalDate.class) .validatedBy(FutureOrPresentValidatorForLocalDateTime.class) .validatedBy(FutureOrPresentValidatorForLocalTime.class) .validatedBy(FutureOrPresentValidatorForMinguoDate.class) .validatedBy(FutureOrPresentValidatorForMonthDay.class) .validatedBy(FutureOrPresentValidatorForOffsetDateTime.class) .validatedBy(FutureOrPresentValidatorForOffsetTime.class) .validatedBy(FutureOrPresentValidatorForThaiBuddhistDate.class) .validatedBy(FutureOrPresentValidatorForYear.class) .validatedBy(FutureOrPresentValidatorForYearMonth.class) .validatedBy(FutureOrPresentValidatorForZonedDateTime.class); }