Search in sources :

Example 26 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project syndesis by syndesisio.

the class Application method localValidatorFactoryBean.

@Bean
public Validator localValidatorFactoryBean(final ResteasyProviderFactory factory, final MessageSource messageSource, final ResourcePatternResolver resolver) throws IOException {
    final LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
    localValidatorFactoryBean.setValidationMessageSource(messageSource);
    final Resource[] mappings = resolver.getResources("classpath*:/META-INF/validation/*.xml");
    localValidatorFactoryBean.setMappingLocations(mappings);
    factory.register(new ValidatorContextResolver(localValidatorFactoryBean));
    return localValidatorFactoryBean;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Resource(org.springframework.core.io.Resource) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 27 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project community by GoogleCloudPlatform.

the class ValidatorTests method createValidator.

private Validator createValidator() {
    LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
    localValidatorFactoryBean.afterPropertiesSet();
    return localValidatorFactoryBean;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 28 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project spring-petclinic by spring-projects.

the class ValidatorTests method createValidator.

private Validator createValidator() {
    LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
    localValidatorFactoryBean.afterPropertiesSet();
    return localValidatorFactoryBean;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 29 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project xm-ms-entity by xm-online.

the class DatabaseConfiguration method entityManagerFactory.

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, MultiTenantConnectionProvider multiTenantConnectionProviderImpl, CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl, LocalValidatorFactoryBean localValidatorFactoryBean) {
    Map<String, Object> properties = new HashMap<>();
    properties.putAll(jpaProperties.getHibernateProperties(dataSource));
    properties.put(org.hibernate.cfg.Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
    properties.put(org.hibernate.cfg.Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
    properties.put(org.hibernate.cfg.Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);
    properties.put(JPA_VALIDATION_FACTORY, localValidatorFactoryBean);
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(JPA_PACKAGES);
    em.setJpaVendorAdapter(jpaVendorAdapter());
    em.setJpaPropertyMap(properties);
    return em;
}
Also used : HashMap(java.util.HashMap) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 30 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project spring-framework by spring-projects.

the class ModelAttributeMethodArgumentResolverTests method setup.

@BeforeEach
void setup() {
    LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
    validator.afterPropertiesSet();
    ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
    initializer.setValidator(validator);
    this.bindContext = new BindingContext(initializer);
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) ConfigurableWebBindingInitializer(org.springframework.web.bind.support.ConfigurableWebBindingInitializer) BindingContext(org.springframework.web.reactive.BindingContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)32 Bean (org.springframework.context.annotation.Bean)12 Test (org.junit.jupiter.api.Test)6 ApplicationContext (org.springframework.context.ApplicationContext)5 ConfigurableWebBindingInitializer (org.springframework.web.bind.support.ConfigurableWebBindingInitializer)4 Locale (java.util.Locale)2 Before (org.junit.Before)2 Test (org.junit.Test)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 MifosBeanValidator (org.mifos.platform.validation.MifosBeanValidator)2 StubValidationContext (org.mifos.ui.validation.StubValidationContext)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 MessageInterpolatorFactory (org.springframework.boot.validation.MessageInterpolatorFactory)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 Role (org.springframework.context.annotation.Role)2 StaticMessageSource (org.springframework.context.support.StaticMessageSource)2 FormattingConversionService (org.springframework.format.support.FormattingConversionService)2 Validator (org.springframework.validation.Validator)2 RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter)2 FAIL_ON_UNKNOWN_PROPERTIES (com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)1