/** * create hibernate validation configuration * * @return */ protected HibernateValidatorConfiguration createConfiguration() { HibernateValidatorConfiguration configuration = null; if (this.isIgnoreClassHierarchy()) { ValidationProviderResolver resolver = new ValidationProviderResolver() { /** * (non-Javadoc) * * @see javax.validation.ValidationProviderResolver#getValidationProviders() */ @Override public List<ValidationProvider<?>> getValidationProviders() { List<ValidationProvider<?>> providers = new ArrayList<ValidationProvider<?>>(1); providers.add(new HibernateValidator513()); return providers; } }; configuration = Validation.byProvider(HibernateValidator513.class).providerResolver(resolver).configure(); } else { configuration = Validation.byProvider(HibernateValidator.class).configure(); } configuration.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator( MESSAGES))); return configuration; }
@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); }
@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() ) ); }
/** * {@inheritDoc} */ @Override public ValidationConfig getContext(Class<?> type) { return new ValidationConfig() .messageInterpolator( // TODO: ResourceBundleMessageInterpolator always return default messages new ResourceBundleMessageInterpolator( new PlatformResourceBundleLocator(Messages.RESOURCE_BUNDLE_BASE_NAME))); }
public static MessageInterpolator buildMessageInterpolator(MessageSource messageSource) { return new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(messageSource)); }
@Bean public LocalValidatorFactoryBean validator() { LocalValidatorFactoryBean bean = new LocalValidatorFactoryBean(); bean.setMessageInterpolator(new ResourceBundleMessageInterpolator()); return bean; }
protected ResourceBundleMessageInterpolator newResourceBundleMessageInterpolator() { return new ResourceBundleMessageInterpolator(newResourceBundleLocator()); }
public MessageResolverInterpolator(final MessageResolver messageResolver) { ArgUtils.notNull("messageResolver", "messageResolver"); this.messageInterpolator = new ResourceBundleMessageInterpolator( new MessageResolverResourceBundleLocator(messageResolver)); }