use of jakarta.validation.Configuration in project hibernate-validator by hibernate.
the class URLValidatorTest method url_validator_using_regexp_only_can_be_configured_via_xml.
@Test
@TestForIssue(jiraKey = "HV-920")
public void url_validator_using_regexp_only_can_be_configured_via_xml() {
Configuration config = ValidatorUtil.getConfiguration();
InputStream mappingStream = URLValidatorTest.class.getResourceAsStream("mapping.xml");
config.addMapping(mappingStream);
DelegatingConstraintValidatorFactory constraintValidatorFactory = new DelegatingConstraintValidatorFactory(config.getDefaultConstraintValidatorFactory());
config.constraintValidatorFactory(constraintValidatorFactory);
assertDefaultURLConstraintValidatorOverridden(config, constraintValidatorFactory);
}
use of jakarta.validation.Configuration in project hibernate-validator by hibernate.
the class ValidatorFactoryBean method createValidationXmlValueExtractors.
private Set<ValueExtractorDescriptor> createValidationXmlValueExtractors(Configuration<?> config) {
BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
Set<String> valueExtractorFqcns = bootstrapConfiguration.getValueExtractorClassNames();
@SuppressWarnings("unchecked") Set<ValueExtractorDescriptor> valueExtractorDescriptors = valueExtractorFqcns.stream().map(fqcn -> createInstance((Class<? extends ValueExtractor<?>>) run(LoadClass.action(fqcn, null)))).map(ve -> new ValueExtractorDescriptor(ve)).collect(Collectors.toSet());
return valueExtractorDescriptors;
}
use of jakarta.validation.Configuration in project beanvalidation-tck by eclipse-ee4j.
the class ConfigurationTest method testProviderUnderTestDefinesSubInterfaceOfConfiguration.
@Test
@SpecAssertion(section = Sections.VALIDATIONAPI_BOOTSTRAPPING_CONFIGURATION, id = "l")
public void testProviderUnderTestDefinesSubInterfaceOfConfiguration() {
boolean foundSubinterfaceOfConfiguration = false;
Type[] types = TestUtil.getValidationProviderUnderTest().getClass().getGenericInterfaces();
for (Type type : types) {
if (type instanceof ParameterizedType) {
ParameterizedType paramType = (ParameterizedType) type;
Type[] typeArguments = paramType.getActualTypeArguments();
for (Type typeArgument : typeArguments) {
if (typeArgument instanceof Class && Configuration.class.isAssignableFrom((Class<?>) typeArgument)) {
foundSubinterfaceOfConfiguration = true;
}
}
}
}
assertTrue(foundSubinterfaceOfConfiguration, "Could not find subinterface of Configuration");
}
use of jakarta.validation.Configuration in project resteasy by resteasy.
the class AbstractValidatorContextResolver method getValidatorFactory.
// this used to be initialized in a static block, but I was having trouble class loading the context resolver in some
// environments. So instead of failing and logging a warning when the resolver is instantiated at deploy time
// we log any validation warning when trying to obtain the ValidatorFactory.
ValidatorFactory getValidatorFactory() {
ValidatorFactory tmpValidatorFactory = validatorFactory;
if (tmpValidatorFactory == null) {
synchronized (RD_LOCK) {
tmpValidatorFactory = validatorFactory;
if (tmpValidatorFactory == null) {
try {
// Also look up java:comp/env
Context context = new InitialContext();
validatorFactory = tmpValidatorFactory = ValidatorFactory.class.cast(context.lookup("java:comp/ValidatorFactory"));
LogMessages.LOGGER.debug(Messages.MESSAGES.usingValidatorFactorySupportsCDI(validatorFactory));
} catch (NamingException e) {
LogMessages.LOGGER.info(Messages.MESSAGES.usingValidatorFactoryDoesNotSupportCDI());
Configuration<?> config = Validation.byDefaultProvider().configure();
validatorFactory = tmpValidatorFactory = config.buildValidatorFactory();
}
}
}
}
return tmpValidatorFactory;
}
use of jakarta.validation.Configuration in project today-framework by TAKETODAY.
the class BeanValidationConfig method hibernateValidator.
@MissingBean
@SuppressWarnings({ "unchecked", "rawtypes" })
@ConditionalOnClass(name = "org.hibernate.validator.HibernateValidator")
DefaultJavaxValidator hibernateValidator(ApplicationContext context) {
final Class<ValidationProvider> aClass = ClassUtils.load("org.hibernate.validator.HibernateValidator");
final Configuration hibernateValidatorConfig = Validation.byProvider(aClass).configure().messageInterpolator(new ContextMessageInterpolator(context)).parameterNameProvider(new ContextParameterNameProvider());
return new DefaultJavaxValidator(hibernateValidatorConfig);
}
Aggregations