Examples of StringLengthValidator


Examples of com.tll.client.validate.StringLengthValidator

    tb.setMaxLength(maxLen < 0 ? 256 : maxLen);
    if(maxLen == -1) {
      removeValidator(StringLengthValidator.class);
    }
    else {
      addValidator(new StringLengthValidator(-1, maxLen));
    }
  }
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

            }
            if (r.nextBoolean()) {
                f.setCaption(null);
            }

            f.addValidator(new StringLengthValidator("Error", 10, 8, false));
        }
        // createLayout(l1, new
        // ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL),
        // "1000px", "150px", "50px", null, false);
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

    public void init() {

        final LegacyWindow main = new LegacyWindow("#1811");
        setMainWindow(main);

        Validator strLenValidator = new StringLengthValidator(
                "String must be at least 3 chars long and non-null", 3, -1,
                false);

        TextField tf1 = new TextField(
                "Text field with default settings (required=false)");
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

        property = new ObjectProperty<String>("original");
        field.setPropertyDataSource(property);
    }

    public void testMultipleValidators() {
        field.addValidator(new StringLengthValidator(
                "Length not between 1 and 3", 1, 3, false));
        field.addValidator(new StringLengthValidator(
                "Length not between 2 and 4", 2, 4, false));

        // fails
        try {
            field.setValue("a");
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

            // should fail
        }
    }

    public void testRemoveValidator() {
        Validator validator1 = new StringLengthValidator(
                "Length not between 1 and 3", 1, 3, false);
        Validator validator2 = new StringLengthValidator(
                "Length not between 2 and 4", 2, 4, false);

        field.addValidator(validator1);
        field.addValidator(validator2);
        field.removeValidator(validator1);
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

        // succeeds
        field.setValue("abcd");
    }

    public void testRemoveAllValidators() {
        Validator validator1 = new StringLengthValidator(
                "Length not between 1 and 3", 1, 3, false);
        Validator validator2 = new StringLengthValidator(
                "Length not between 2 and 4", 2, 4, false);

        field.addValidator(validator1);
        field.addValidator(validator2);
        field.removeAllValidators();
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

                });
        addComponent(commitButton);
        addComponent(discardButton);
        addComponent(showBean);
        email.addValidator(new EmailValidator("Must be a valid address"));
        lastName.addValidator(new StringLengthValidator("Must be min 5 chars",
                5, null, true));

        age.addValidator(new IntegerRangeValidator(
                "Must be between 0 and 150, {0} is not", 0, 150));
        sex.setPageLength(0);
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

        final Form form = new Form(new VerticalLayout());

        // simple validators

        TextField tf = new TextField("A field, must contain 1-2 chars");
        tf.addValidator(new StringLengthValidator("Invalid length", 1, 2, false));
        tf.setRequired(true);
        tf.setValue("ab");
        form.addField("a", tf);

        tf = new TextField("A field, must contain an integer");
        tf.addValidator(new IntegerValidator("Invalid integer {0}"));
        tf.setRequired(true);
        tf.setValue("123");
        form.addField("b", tf);

        tf = new TextField("A field, must contain an integer or be empty");
        tf.addValidator(new IntegerValidator("Invalid integer {0}"));
        tf.setValue("-321");
        form.addField("c", tf);

        tf = new TextField(
                "A field, must contain a floating point number or be empty");
        tf.addValidator(new DoubleValidator("Invalid double {0}"));
        tf.setValue("-123.45e6");
        form.addField("d", tf);

        tf = new TextField(
                "A field, must contain an e-mail address or be empty");
        tf.addValidator(new EmailValidator("Invalid e-mail address {0}"));
        tf.setValue("a.b@example.com");
        form.addField("e", tf);

        // regular expressions

        tf = new TextField("A field, must match the regular expression a.*b.*c");
        tf.addValidator(new RegexpValidator("a.*b.*c",
                "{0} does not match the regular expression"));
        tf.setValue("aagsabeqgc");
        form.addField("f", tf);

        tf = new TextField(
                "A field, must contain the regular expression a.*b.*c");
        tf.addValidator(new RegexpValidator("a.*b.*c", false,
                "{0} does not contain the regular expression"));
        tf.setValue("aagsabeqgc");
        form.addField("g", tf);

        tf = new TextField(
                "A field, must match the regular expression ^a.*b.*c$");
        tf.addValidator(new RegexpValidator("^a.*b.*c$", false,
                "{0} does not match the regular expression with ^ and $"));
        tf.setValue("aagsabeqgc");
        form.addField("h", tf);

        tf = new TextField(
                "A field, must contain the regular expression ^a.*b.*c$");
        tf.addValidator(new RegexpValidator("^a.*b.*c$", false,
                "{0} does not contain the regular expression with ^ and $"));
        tf.setValue("aagsabeqgc");
        form.addField("i", tf);

        // TODO CompositeValidator
        tf = new TextField(
                "A field, must be a floating point number with 4-5 chars");
        CompositeValidator cv = new CompositeValidator(CombinationMode.AND,
                "The field must contain a floating point number with 4-5 characters");
        cv.addValidator(new StringLengthValidator(
                "String length of '{0}' should be 4-5 characters", 4, 5, false));
        cv.addValidator(new DoubleValidator(
                "{0} must be a floating point number"));
        tf.addValidator(cv);
        tf.setValue("12.34");
        form.addField("j", tf);

        tf = new TextField(
                "A field, must be a floating point number or 4-5 chars");
        cv = new CompositeValidator(CombinationMode.OR,
                "The field must contain a floating point  or with 4-5 characters");
        cv.addValidator(new StringLengthValidator(
                "String length of '{0}' should be 4-5 characters", 4, 5, false));
        cv.addValidator(new DoubleValidator(
                "{0} must be a floating point number"));
        tf.addValidator(cv);
        tf.setValue("12.34g");
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

    @Override
    protected void setup() {
        form = new Form();
        form.setFooter(null);
        TextField tf = new TextField("A field, must contain 1-2 chars");
        tf.addValidator(new StringLengthValidator("Invalid length", 1, 2, false));
        tf.setRequired(true);

        form.addField("a", tf);

        Button b = new Button("Commit", new ClickListener() {
View Full Code Here

Examples of com.vaadin.data.validator.StringLengthValidator

    @Override
    protected void setup() {
        tf = new TextField("A field, must contain 1-2 chars",
                new ObjectProperty<String>("a"));
        tf.addValidator(new StringLengthValidator("Invalid length", 1, 2, false));
        tf.setBuffered(true);
        tf.setRequired(true);

        Button b = new Button("Commit", new ClickListener() {
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.