Search in sources :

Example 6 with MessageInterpolator

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;
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) MessageInterpolator(javax.validation.MessageInterpolator)

Example 7 with MessageInterpolator

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);
}
Also used : ValidatorContext(javax.validation.ValidatorContext) Validator(javax.validation.Validator) MessageInterpolator(javax.validation.MessageInterpolator) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with MessageInterpolator

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);
}
Also used : ExecutableType(javax.validation.executable.ExecutableType) ResourceBundleMessageInterpolator(org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator) GeneralValidatorImpl(org.jboss.resteasy.plugins.validation.GeneralValidatorImpl) PlatformResourceBundleLocator(org.hibernate.validator.resourceloading.PlatformResourceBundleLocator) BootstrapConfiguration(javax.validation.BootstrapConfiguration) ResourceBundleLocator(org.hibernate.validator.spi.resourceloading.ResourceBundleLocator) PlatformResourceBundleLocator(org.hibernate.validator.resourceloading.PlatformResourceBundleLocator) ResourceBundleMessageInterpolator(org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator) MessageInterpolator(javax.validation.MessageInterpolator)

Aggregations

MessageInterpolator (javax.validation.MessageInterpolator)8 Test (org.junit.Test)4 ValidatorFactory (javax.validation.ValidatorFactory)3 Validator (javax.validation.Validator)2 ExecutableType (javax.validation.executable.ExecutableType)2 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)2 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 Map (java.util.Map)1 NamingException (javax.naming.NamingException)1 BootstrapConfiguration (javax.validation.BootstrapConfiguration)1 ConstraintValidatorFactory (javax.validation.ConstraintValidatorFactory)1 ConstraintViolation (javax.validation.ConstraintViolation)1 ParameterNameProvider (javax.validation.ParameterNameProvider)1 TraversableResolver (javax.validation.TraversableResolver)1 ValidationException (javax.validation.ValidationException)1 ValidatorContext (javax.validation.ValidatorContext)1 PropertyType (org.apache.openejb.jee.bval.PropertyType)1