Search in sources :

Example 71 with ValidatorFactory

use of javax.validation.ValidatorFactory in project wildfly by wildfly.

the class BeanValidationFactoryDeployer method undeploy.

@Override
public void undeploy(DeploymentUnit context) {
    ValidatorFactory validatorFactory = context.getAttachment(BeanValidationAttachments.VALIDATOR_FACTORY);
    if ((validatorFactory != null) && (!WeldDeploymentMarker.isPartOfWeldDeployment(context))) {
        // If the ValidatorFactory is not CDI-enabled, close it here. Otherwise, it's
        // closed via CdiValidatorFactoryService before the Weld service is stopped.
        validatorFactory.close();
    }
    context.removeAttachment(BeanValidationAttachments.VALIDATOR_FACTORY);
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory)

Example 72 with ValidatorFactory

use of javax.validation.ValidatorFactory in project ORCID-Source by ORCID.

the class ManagePasswordOptionsValidationFormTest method resetValidator.

@Before
public void resetValidator() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    validator = factory.getValidator();
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) Before(org.junit.Before)

Example 73 with ValidatorFactory

use of javax.validation.ValidatorFactory in project ORCID-Source by ORCID.

the class ChangePasswordFormValidatorTest method resetValidator.

@Before
public void resetValidator() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    validator = factory.getValidator();
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) Before(org.junit.Before)

Example 74 with ValidatorFactory

use of javax.validation.ValidatorFactory in project API by ca-cwds.

the class ParticipantTest method setup.

@Before
public void setup() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    validator = factory.getValidator();
    MAPPER.configure(SerializationFeature.INDENT_OUTPUT, true);
    Participant validParticipant = this.validParticipant();
    roles.add("Victim");
    Address address = new Address("", "", "123 First St", "San Jose", "CA", 94321, "Home");
    addresses.add(address);
    MAPPER.configure(SerializationFeature.INDENT_OUTPUT, true);
    when(mockedParticipantResource.create(eq(validParticipant))).thenReturn(Response.status(Response.Status.NO_CONTENT).entity(null).build());
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) Before(org.junit.Before)

Example 75 with ValidatorFactory

use of javax.validation.ValidatorFactory in project oxCore by GluuFederation.

the class UIInputContainer method getDefaultValidator.

/**
 * Get the default Bean Validation Validator to read the contraints for a
 * property.
 */
private Validator getDefaultValidator(final FacesContext context) throws FacesException {
    if (!beanValidationPresent) {
        return null;
    }
    ValidatorFactory validatorFactory;
    Object cachedObject = context.getExternalContext().getApplicationMap().get(BeanValidator.VALIDATOR_FACTORY_KEY);
    if (cachedObject instanceof ValidatorFactory) {
        validatorFactory = (ValidatorFactory) cachedObject;
    } else {
        try {
            validatorFactory = Validation.buildDefaultValidatorFactory();
        } catch (ValidationException e) {
            throw new FacesException("Could not build a default Bean Validator factory", e);
        }
        context.getExternalContext().getApplicationMap().put(BeanValidator.VALIDATOR_FACTORY_KEY, validatorFactory);
    }
    return validatorFactory.getValidator();
}
Also used : ValidationException(javax.validation.ValidationException) ValidatorFactory(javax.validation.ValidatorFactory) FacesException(javax.faces.FacesException)

Aggregations

ValidatorFactory (javax.validation.ValidatorFactory)106 Validator (javax.validation.Validator)31 Before (org.junit.Before)28 ConstraintViolation (javax.validation.ConstraintViolation)25 Test (org.junit.Test)17 BeforeClass (org.junit.BeforeClass)13 ConstraintViolationException (javax.validation.ConstraintViolationException)7 HibernateValidatorConfiguration (org.hibernate.validator.HibernateValidatorConfiguration)6 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)6 PlatformResourceBundleLocator (org.hibernate.validator.resourceloading.PlatformResourceBundleLocator)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 BeanManager (javax.enterprise.inject.spi.BeanManager)5 InitialContext (javax.naming.InitialContext)5 ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)5 HashSet (java.util.HashSet)4 NamingException (javax.naming.NamingException)4 ConstraintValidatorFactory (javax.validation.ConstraintValidatorFactory)4 ValidatorContext (javax.validation.ValidatorContext)4 HibernateValidator (org.hibernate.validator.HibernateValidator)4