Package org.apache.tapestry5.beaneditor

Examples of org.apache.tapestry5.beaneditor.Validate


    @Test
    public void field_annotations_are_visible()
    {
        PropertyConduit conduit = source.create(CompositeBean.class, "simple.firstName");

        Validate annotation = conduit.getAnnotation(Validate.class);

        assertNotNull(annotation);

        assertEquals(annotation.value(), "required");
    }
View Full Code Here


    @Test
    public void field_annotations_are_visible()
    {
        PropertyConduit conduit = source.create(CompositeBean.class, "simple.firstName");

        Validate annotation = conduit.getAnnotation(Validate.class);

        assertNotNull(annotation);

        assertEquals(annotation.value(), "required");
    }
View Full Code Here

    @Test
    public void field_annotations_are_visible()
    {
        PropertyConduit conduit = source.create(CompositeBean.class, "simple.firstName");

        Validate annotation = conduit.getAnnotation(Validate.class);

        assertNotNull(annotation);

        assertEquals(annotation.value(), "required");
    }
View Full Code Here

        validatorPattern = Pattern.compile(VALIDATOR_PATTERN);
    }

    public List<String> buildConstraints(Class propertyType, AnnotationProvider annotationProvider)
    {
        Validate annotation = annotationProvider.getAnnotation(Validate.class);

        if (annotation == null)
            return null;

        //TAP5-520: Commas within regular expressions like {n,m} or {n,} or a\,b .
        //We use Negative Lookahead to avoid matching the case a\,b .
        //We use Positive Lookahead to avoid matching cases {n,m} and {n,}.
        //http://www.regular-expressions.info/lookaround.html
        return Arrays.asList(validatorPattern.split(annotation.value()));
    }
View Full Code Here

    @Test
    public void field_annotations_are_visible()
    {
        PropertyConduit conduit = source.create(CompositeBean.class, "simple.firstName");

        Validate annotation = conduit.getAnnotation(Validate.class);

        assertNotNull(annotation);

        assertEquals(annotation.value(), "required");
    }
View Full Code Here

public class ValidateAnnotationConstraintGenerator implements ValidationConstraintGenerator
{

    public List<String> buildConstraints(Class propertyType, AnnotationProvider annotationProvider)
    {
        Validate annotation = annotationProvider.getAnnotation(Validate.class);

        if (annotation == null)
            return null;

        //TAP5-520: Commas within regular expressions like {n,m} or {n,} or a\,b .
        //We use Negative Lookahead to avoid matching the case a\,b .
        //We use Positive Lookahead to avoid matching cases {n,m} and {n,}.
        //http://www.regular-expressions.info/lookaround.html
        return Arrays.asList(annotation.value().split("(?<!\\\\),(?!([0-9]*\\}))"));
    }
View Full Code Here

    @Test
    public void field_annotations_are_visible()
    {
        PropertyConduit conduit = source.create(CompositeBean.class, "simple.firstName");

        Validate annotation = conduit.getAnnotation(Validate.class);

        assertNotNull(annotation);

        assertEquals(annotation.value(), "required");
    }
View Full Code Here

    @Test
    public void single_constraint()
    {
        PropertyConduit conduit = mockPropertyConduit();
        Validate validate = newValidate("required");

        train_getAnnotation(conduit, Validate.class, validate);

        replay();
View Full Code Here

    @Test
    public void multiple_constraints()
    {
        PropertyConduit conduit = mockPropertyConduit();
        Validate validate = newValidate("required,minlength=3,regexp=^([a-zA-Z0-9]{2,4})+$");

        train_getAnnotation(conduit, Validate.class, validate);

        replay();
View Full Code Here

    @Test
    public void regex_ranges_constraints()
    {
        PropertyConduit conduit = mockPropertyConduit();
        Validate validate = newValidate("regexp=^([a]{50,125}[0-9]{2,4})+$,required,567matcher,regexp=a\\,b,regexp=a{1,}");

        train_getAnnotation(conduit, Validate.class, validate);

        replay();
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.beaneditor.Validate

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.