Examples of Validate


Examples of org.apache.tapestry.beaneditor.Validate

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

        train_getAnnotation(conduit, Validate.class, validate);

        replay();
View Full Code Here

Examples of org.apache.tapestry.beaneditor.Validate

    @Test
    public void multiple_constraints()
    {
        PropertyConduit conduit = newPropertyConduit();
        Validate validate = newValidate("required,minlength=3");

        train_getAnnotation(conduit, Validate.class, validate);

        replay();
View Full Code Here

Examples of org.apache.tapestry.beaneditor.Validate

        verify();
    }

    private Validate newValidate(String value)
    {
        Validate annotation = newMock(Validate.class);

        expect(annotation.value()).andReturn(value).atLeastOnce();

        return annotation;
    }
View Full Code Here

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

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

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

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

Examples of org.apache.tapestry5.beaneditor.Validate

        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

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

Examples of org.apache.tapestry5.beaneditor.Validate

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
TOP
Copyright © 2018 www.massapi.com. 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.