Search in sources :

Example 1 with CubaValidationTraversableResolver

use of com.haulmont.cuba.core.sys.validation.CubaValidationTraversableResolver in project cuba by cuba-platform.

the class BeanValidationImpl method getValidatorFactoryConfiguration.

protected HibernateValidatorConfiguration getValidatorFactoryConfiguration(Supplier<Locale> localeSupplier) {
    HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure().clockProvider(new CubaValidationTimeProvider(timeSource)).traversableResolver(new CubaValidationTraversableResolver(metadata, entityStates)).messageInterpolator(new CubaValidationMessagesInterpolator(messages, localeSupplier));
    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;
}
Also used : ConstraintMapping(org.hibernate.validator.cfg.ConstraintMapping) FutureOrPresent(javax.validation.constraints.FutureOrPresent) Past(javax.validation.constraints.Past) Future(javax.validation.constraints.Future) HibernateValidatorConfiguration(org.hibernate.validator.HibernateValidatorConfiguration) CubaValidationTimeProvider(com.haulmont.cuba.core.sys.validation.CubaValidationTimeProvider) CubaValidationTraversableResolver(com.haulmont.cuba.core.sys.validation.CubaValidationTraversableResolver) CubaValidationMessagesInterpolator(com.haulmont.cuba.core.sys.validation.CubaValidationMessagesInterpolator) PastOrPresent(javax.validation.constraints.PastOrPresent)

Aggregations

CubaValidationMessagesInterpolator (com.haulmont.cuba.core.sys.validation.CubaValidationMessagesInterpolator)1 CubaValidationTimeProvider (com.haulmont.cuba.core.sys.validation.CubaValidationTimeProvider)1 CubaValidationTraversableResolver (com.haulmont.cuba.core.sys.validation.CubaValidationTraversableResolver)1 Future (javax.validation.constraints.Future)1 FutureOrPresent (javax.validation.constraints.FutureOrPresent)1 Past (javax.validation.constraints.Past)1 PastOrPresent (javax.validation.constraints.PastOrPresent)1 HibernateValidatorConfiguration (org.hibernate.validator.HibernateValidatorConfiguration)1 ConstraintMapping (org.hibernate.validator.cfg.ConstraintMapping)1