use of javax.validation.ValidatorFactory in project motech by motech.
the class MdsConfig method addBeanValidationFactoryProperty.
private void addBeanValidationFactoryProperty(Properties properties) {
// Datanucleus expects the validator factory as the actual object, not just a string property
ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
properties.put(PropertyNames.PROPERTY_VALIDATION_FACTORY, validatorFactory);
}
use of javax.validation.ValidatorFactory 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.ValidatorFactory in project ART-TIME by Artezio.
the class HoursTest method testValidateNegativeQuantity.
@Test
public void testValidateNegativeQuantity() {
ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
Validator validator = vf.getValidator();
Hours h = new Hours(new Project(), new Date(), new Employee("user"), new HourType("type1"));
h.setQuantity(BigDecimal.valueOf(-1.0));
Set<ConstraintViolation<Hours>> violations = validator.validate(h);
vf.close();
assertFalse(violations.isEmpty());
}
use of javax.validation.ValidatorFactory in project Payara by payara.
the class CompositeUtil method initBeanValidator.
private static synchronized void initBeanValidator() {
if (beanValidator != null) {
return;
}
ClassLoader cl = System.getSecurityManager() == null ? Thread.currentThread().getContextClassLoader() : AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
});
try {
Thread.currentThread().setContextClassLoader(Validation.class.getClassLoader());
ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
ValidatorContext validatorContext = validatorFactory.usingContext();
validatorContext.messageInterpolator(new MessageInterpolatorImpl());
beanValidator = validatorContext.getValidator();
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
use of javax.validation.ValidatorFactory in project keywhiz by square.
the class ValidX500NameValidatorTest method setUp.
@BeforeClass
public static void setUp() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
}
Aggregations