Package com.softwaremill.common.cdi.validation

Examples of com.softwaremill.common.cdi.validation.LengthValidator


            @Length(min = 10, max = 15)
            public String field;

        }

        LengthValidator validator = initializeValidator(AnnotationWrapper.class);

        //when
        boolean valid = validator.isValid("PawelStawicki", context);
        boolean tooShort = validator.isValid("Pawel", context);
        boolean tooLong = validator.isValid("Pawellllllllllllllllllllllllllllllll", context);

        //then
        Assert.assertTrue(valid);
       
        Assert.assertFalse(tooShort);
View Full Code Here


        verify(context).buildConstraintViolationWithTemplate("Value is too long");
    }

    private LengthValidator initializeValidator(Class<?> classWithAnnotation) throws NoSuchFieldException {
        Length constraint = classWithAnnotation.getField("field").getAnnotation(Length.class);
        LengthValidator validator = new LengthValidator();
        validator.initialize(constraint);

        return validator;
    }
View Full Code Here

TOP

Related Classes of com.softwaremill.common.cdi.validation.LengthValidator

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.