org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator Java Examples

The following examples show how to use org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator. 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: ValidationUtil.java    From BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
@PostConstruct
private void init() {
	ValidatorProperties properties = ContextUtil.bean(ValidatorProperties.class);
	HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
	//配置hibernate-validator消息插值源
	MessageInterpolator interpolator = new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator(properties
		.getMessageConfigPath()));
	configuration.messageInterpolator(interpolator);
	//配置快速失败
	configuration.failFast(properties.getFailFast());
	failFast = properties.getFailFast();
	engine = configuration.buildValidatorFactory().getValidator();
}
 
Example #2
Source File: ValidatorContextResolver.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
public GeneralValidator getContext(final Class<?> type) {
    final ResourceBundleLocator resourceBundleLocator = new PlatformResourceBundleLocator("messages");
    final MessageInterpolator messageInterpolator = new ResourceBundleMessageInterpolator(resourceBundleLocator);
    final Configuration<?> config = Validation.byDefaultProvider().configure()
        .messageInterpolator(messageInterpolator);
    final BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    final boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
    final Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration
        .getDefaultValidatedExecutableTypes();

    return new GeneralValidatorImpl(validatorFactory, isExecutableValidationEnabled,
        defaultValidatedExecutableTypes);
}
 
Example #3
Source File: ValidationConfiguration.java    From edison-microservice with Apache License 2.0 5 votes vote down vote up
@Bean
public LocalValidatorFactoryBean validator() {
    PlatformResourceBundleLocator resourceBundleLocator =
            new PlatformResourceBundleLocator(ResourceBundleMessageInterpolator.USER_VALIDATION_MESSAGES, null, true);

    LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean();
    factoryBean.setMessageInterpolator(new ResourceBundleMessageInterpolator(resourceBundleLocator));
    return factoryBean;
}
 
Example #4
Source File: ValidationFeature.java    From ameba with MIT License 5 votes vote down vote up
@Override
public ValidationConfig getContext(final Class<?> type) {
    return new ValidationConfig()
            .constraintValidatorFactory(resourceContext.getResource(InjectingConstraintValidatorFactory.class))
            .parameterNameProvider(new ParanamerParameterNameProvider())
            .messageInterpolator(
                    new ResourceBundleMessageInterpolator(
                            buildBundleLocator(VALIDATION_MESSAGE_BUNDLE_NAME),
                            buildBundleLocator(Messages.BUNDLE_NAME),
                            mode.isProd()
                    )
            );
}
 
Example #5
Source File: LocalValidatorFactoryBean.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public static MessageInterpolator buildMessageInterpolator(MessageSource messageSource) {
	return new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(messageSource));
}
 
Example #6
Source File: LocalValidatorFactoryBean.java    From java-technology-stack with MIT License 4 votes vote down vote up
public static MessageInterpolator buildMessageInterpolator(MessageSource messageSource) {
	return new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(messageSource));
}
 
Example #7
Source File: ParameterValidator.java    From servicecomb-java-chassis with Apache License 2.0 4 votes vote down vote up
private AbstractMessageInterpolator messageInterpolator() {
  if (useResourceBundleMessageInterpolator()) {
    return new ResourceBundleMessageInterpolator();
  }
  return new ParameterMessageInterpolator();
}
 
Example #8
Source File: ParameterValidatorFilter.java    From servicecomb-java-chassis with Apache License 2.0 4 votes vote down vote up
private AbstractMessageInterpolator messageInterpolator() {
  if (useResourceBundleMessageInterpolator()) {
    return new ResourceBundleMessageInterpolator();
  }
  return new ParameterMessageInterpolator();
}
 
Example #9
Source File: LocalValidatorFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public static MessageInterpolator buildMessageInterpolator(MessageSource messageSource) {
	return new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(messageSource));
}
 
Example #10
Source File: LocalValidatorFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public static MessageInterpolator buildMessageInterpolator(MessageSource messageSource) {
	return new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(messageSource));
}
 
Example #11
Source File: ActionValidator.java    From lastaflute with Apache License 2.0 4 votes vote down vote up
protected ResourceBundleMessageInterpolator newResourceBundleMessageInterpolator() {
    return new ResourceBundleMessageInterpolator(newResourceBundleLocator());
}