Search in sources :

Example 21 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project FP-PSP-SERVER by FundacionParaguaya.

the class WebMvcConfig method validator.

@Bean
public LocalValidatorFactoryBean validator() {
    LocalValidatorFactoryBean factory = new LocalValidatorFactoryBean();
    factory.setMessageInterpolator(i18n());
    factory.setValidationMessageSource(messageSource());
    return factory;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 22 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project Flare-event-calendar by PollubCafe.

the class MessagesConfig method validator.

@Bean
public Validator validator() {
    final LocalValidatorFactoryBean factory = new LocalValidatorFactoryBean();
    factory.setValidationMessageSource(messageSource());
    return factory;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 23 with LocalValidatorFactoryBean

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

the class ValidatorAdapterTests method wrapperInvokesCallbackOnNonManagedBean.

@Test
void wrapperInvokesCallbackOnNonManagedBean() {
    this.contextRunner.withUserConfiguration(NonManagedBeanConfig.class).run((context) -> {
        LocalValidatorFactoryBean validator = context.getBean(NonManagedBeanConfig.class).validator;
        then(validator).should().setApplicationContext(any(ApplicationContext.class));
        then(validator).should().afterPropertiesSet();
        then(validator).should(never()).destroy();
        context.close();
        then(validator).should().destroy();
    });
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) ApplicationContext(org.springframework.context.ApplicationContext) Test(org.junit.jupiter.api.Test)

Example 24 with LocalValidatorFactoryBean

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

the class ValidatorAdapterTests method wrapperDoesNotInvokeCallbackOnManagedBean.

@Test
void wrapperDoesNotInvokeCallbackOnManagedBean() {
    this.contextRunner.withUserConfiguration(ManagedBeanConfig.class).run((context) -> {
        LocalValidatorFactoryBean validator = context.getBean(ManagedBeanConfig.class).validator;
        then(validator).should(never()).setApplicationContext(any(ApplicationContext.class));
        then(validator).should(never()).afterPropertiesSet();
        then(validator).should(never()).destroy();
        context.close();
        then(validator).should(never()).destroy();
    });
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) ApplicationContext(org.springframework.context.ApplicationContext) Test(org.junit.jupiter.api.Test)

Example 25 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project erp-catering by liuyandong33.

the class HibernateValidatorConfiguration method localValidatorFactoryBean.

@Bean(name = "validator")
public Validator localValidatorFactoryBean() {
    LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
    localValidatorFactoryBean.setProviderClass(HibernateValidator.class);
    localValidatorFactoryBean.setValidationMessageSource(messageSource);
    return localValidatorFactoryBean;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

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