org.hibernate.validator.resourceloading.PlatformResourceBundleLocator Java Examples
The following examples show how to use
org.hibernate.validator.resourceloading.PlatformResourceBundleLocator.
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 |
@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 |
@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 |
@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; }