package com.fzm.mall.server.admin.config;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 *
 * @author wulixian
 * @since 2021-03-03
 */
@Configuration
public class ValidationConfiguration {

    @Resource
    private MessageSource messageSource;

    @NotNull
    @Bean
    public LocalValidatorFactoryBean getValidator() {
        LocalValidatorFactoryBean bean = new LocalValidatorFactoryBean();
        bean.setValidationMessageSource(messageSource);
        return bean;
    }

}
