use of javax.validation.MessageInterpolator in project wicket by apache.
the class DefaultValidatorProvider method get.
@Override
public Validator get() {
if (validator == null) {
Configuration<?> config = Validation.byDefaultProvider().configure();
MessageInterpolator interpolator = config.getDefaultMessageInterpolator();
interpolator = new SessionLocaleInterpolator(interpolator);
ValidatorFactory factory = config.messageInterpolator(interpolator).buildValidatorFactory();
validator = factory.getValidator();
}
return validator;
}
use of javax.validation.MessageInterpolator in project ART-TIME by Artezio.
the class PeriodValidatorTest method testCreateBeanValidator.
@Test
public void testCreateBeanValidator() {
ValidatorContext validatorContext = createMock(ValidatorContext.class);
MessageInterpolator messageInterpolator = createMock(MessageInterpolator.class);
expect(validatorFactory.usingContext()).andReturn(validatorContext);
expect(validatorFactory.getMessageInterpolator()).andReturn(messageInterpolator);
expect(validatorContext.messageInterpolator(anyObject())).andReturn(validatorContext);
expect(validatorContext.getValidator()).andReturn(validator);
replay(validatorFactory, validatorContext);
Validator actual = periodValidator.createBeanValidator(facesContext);
verify(validatorFactory, validatorContext);
assertNotNull(actual);
}
use of javax.validation.MessageInterpolator in project syndesis by syndesisio.
the class ValidatorContextResolver method getContext.
@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);
}
Aggregations