Package com.vaadin.data.validator

Examples of com.vaadin.data.validator.BeanValidator


    @Override
    public void unbind(Field<?> field) throws BindException {
        super.unbind(field);

        BeanValidator removed = defaultValidators.remove(field);
        if (removed != null) {
            field.removeValidator(removed);
        }
    }
View Full Code Here


    protected void configureField(Field<?> field) {
        super.configureField(field);
        // Add Bean validators if there are annotations
        if (isBeanValidationImplementationAvailable()
                && !defaultValidators.containsKey(field)) {
            BeanValidator validator = new BeanValidator(beanType,
                    getPropertyId(field).toString());
            field.addValidator(validator);
            if (field.getLocale() != null) {
                validator.setLocale(field.getLocale());
            }
            defaultValidators.put(field, validator);
        }
    }
View Full Code Here

import com.vaadin.ui.Field;

public class TestBeanValidation {
    @Test(expected = InvalidValueException.class)
    public void testBeanValidationNull() {
        BeanValidator validator = new BeanValidator(BeanToValidate.class,
                "firstname");
        validator.validate(null);
    }
View Full Code Here

        validator.validate(null);
    }

    @Test(expected = InvalidValueException.class)
    public void testBeanValidationStringTooShort() {
        BeanValidator validator = new BeanValidator(BeanToValidate.class,
                "firstname");
        validator.validate("aa");
    }
View Full Code Here

        validator.validate("aa");
    }

    @Test
    public void testBeanValidationStringOk() {
        BeanValidator validator = new BeanValidator(BeanToValidate.class,
                "firstname");
        validator.validate("aaa");
    }
View Full Code Here

        validator.validate("aaa");
    }

    @Test(expected = InvalidValueException.class)
    public void testBeanValidationIntegerTooSmall() {
        BeanValidator validator = new BeanValidator(BeanToValidate.class, "age");
        validator.validate(17);
    }
View Full Code Here

        validator.validate(17);
    }

    @Test
    public void testBeanValidationIntegerOk() {
        BeanValidator validator = new BeanValidator(BeanToValidate.class, "age");
        validator.validate(18);
    }
View Full Code Here

        validator.validate(18);
    }

    @Test(expected = InvalidValueException.class)
    public void testBeanValidationTooManyDigits() {
        BeanValidator validator = new BeanValidator(BeanToValidate.class,
                "decimals");
        validator.validate("1234.567");
    }
View Full Code Here

        validator.validate("1234.567");
    }

    @Test
    public void testBeanValidationDigitsOk() {
        BeanValidator validator = new BeanValidator(BeanToValidate.class,
                "decimals");
        validator.validate("123.45");
    }
View Full Code Here

    }

    @Test
    public void testBeanValidationException_OneValidationError() {
        InvalidValueException[] causes = null;
        BeanValidator validator = new BeanValidator(BeanToValidate.class,
                "lastname");
        try {
            validator.validate(null);
        } catch (InvalidValueException e) {
            causes = e.getCauses();
        }

        Assert.assertEquals(1, causes.length);
View Full Code Here

TOP

Related Classes of com.vaadin.data.validator.BeanValidator

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.