Package org.hibernate.validator.cfg

Examples of org.hibernate.validator.cfg.ConstraintMapping


    private ValidatorFactory initFactory() {
        final ClassLoader oldTCCL = SecurityActions.getContextClassLoader();
        try {
            SecurityActions.setContextClassLoader(classLoader);
            if (configuration == null) {
                ConstraintMapping mapping = new ConstraintMapping();
                HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).providerResolver(new JbossProviderResolver()).configure();
                config.addMapping(mapping);
                ValidatorFactory factory = config.buildValidatorFactory();
                return factory;
View Full Code Here


    private ValidatorFactory initFactory() {
        final ClassLoader oldTCCL = SecurityActions.getContextClassLoader();
        try {
            SecurityActions.setContextClassLoader(oldTCCL);
            ConstraintMapping mapping = new ConstraintMapping();
            HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).providerResolver(new JbossProviderResolver()).configure();
            config.addMapping(mapping);
            ValidatorFactory factory = config.buildValidatorFactory();
            return factory;
        } finally {
View Full Code Here

    @Test
    public void testCustomMessageInterpolation() {

        HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
        Assert.assertNotNull(configuration);
        ConstraintMapping mapping = new ConstraintMapping();
        mapping.type(Employee.class).property("firstName", FIELD)
                .constraint(new EmailDef().message("Invalid Email!You have entered:--\\{${validatedValue}\\}"));

        final MessageInterpolator messageInterpolator = new ValueFormatterMessageInterpolator();
        configuration.messageInterpolator(messageInterpolator);
        configuration.addMapping(mapping);
View Full Code Here

    private ValidatorFactory initFactory() {
        final ClassLoader oldTCCL = SecurityActions.getContextClassLoader();
        try {
            SecurityActions.setContextClassLoader(oldTCCL);
            if (configuration == null) {
                ConstraintMapping mapping = new ConstraintMapping();
                HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).providerResolver(new JbossProviderResolver()).configure();
                config.addMapping(mapping);
                ValidatorFactory factory = config.buildValidatorFactory();
                return factory;
View Full Code Here

    private ValidatorFactory initFactory() {
        final ClassLoader oldTCCL = SecurityActions.getThreadContextClassLoader();
        try {
            SecurityActions.setThreadContextClassLoader(classLoader);
            if (configuration == null) {
                ConstraintMapping mapping = new ConstraintMapping();
                HibernateValidatorConfiguration config =
                    Validation.byProvider(HibernateValidator.class).providerResolver(new JBossProviderResolver()).configure();
                config.addMapping(mapping);
                ValidatorFactory factory = config.buildValidatorFactory();
                return factory;
View Full Code Here

    public Validator getValidator() {
        return getValidatorFactory().getValidator();
    }

    public ValidatorFactory getValidatorFactory() {
        ConstraintMapping mapping = new ConstraintMapping();
        HibernateValidatorConfiguration config = Validation.byProvider( HibernateValidator.class ).providerResolver(this).configure();
        config.addMapping( mapping );
        ValidatorFactory factory = config.buildValidatorFactory();
        return factory;
    }
View Full Code Here

    private ValidatorFactory initFactory() {
        final ClassLoader oldTCCL = SecurityActions.getContextClassLoader();
        try {
            SecurityActions.setContextClassLoader(oldTCCL);
            if (configuration == null) {
                ConstraintMapping mapping = new ConstraintMapping();
                HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).providerResolver(new JbossProviderResolver()).configure();
                config.addMapping(mapping);
                ValidatorFactory factory = config.buildValidatorFactory();
                return factory;
View Full Code Here

  }

  @SuppressWarnings("deprecation")
  public final ConstraintMapping createConstraintMapping() {
    //TODO: create internal implementation and return this
    return new ConstraintMapping();
  }
View Full Code Here

    private ValidatorFactory initFactory() {
        final ClassLoader oldTCCL = SecurityActions.getContextClassLoader();
        try {
            SecurityActions.setContextClassLoader(oldTCCL);
            if (configuration == null) {
                ConstraintMapping mapping = new ConstraintMapping();
                HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).providerResolver(new JbossProviderResolver()).configure();
                config.addMapping(mapping);
                ValidatorFactory factory = config.buildValidatorFactory();
                return factory;
View Full Code Here

  }

  @Test
  @TestForIssue(jiraKey = "HV-500")
  public void testMultipleConstraintMappings() {
    ConstraintMapping marathonMapping = config.createConstraintMapping();
    marathonMapping.type( Marathon.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() );

    ConstraintMapping runnerMapping = config.createConstraintMapping();
    runnerMapping.type( Runner.class )
        .property( "name", METHOD )
        .constraint( new NotNullDef() );

    config.addMapping( marathonMapping );
    config.addMapping( runnerMapping );
View Full Code Here

TOP

Related Classes of org.hibernate.validator.cfg.ConstraintMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.