Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompositeValidator has wrong status #413

Closed
sideisra opened this issue Jun 28, 2016 · 1 comment
Closed

CompositeValidator has wrong status #413

sideisra opened this issue Jun 28, 2016 · 1 comment
Labels
Milestone

Comments

@sideisra
Copy link
Contributor

When a CompositeValidator has two other validators which return a similar message when they are invalid, the validation status of the CompositeValidator is true but should be false.

Unittest to reproduce the bug:

@Test
public void test() {
    final StringProperty prop1 = new SimpleStringProperty();
    final StringProperty prop2 = new SimpleStringProperty();
    final Validator notEmpty1 = new FunctionBasedValidator<>(prop1, v -> {
        if (Strings.isNullOrEmpty(v)) {
            return ValidationMessage.error("msg");
        }
        return null;
    });
    final Validator notEmpty2 = new FunctionBasedValidator<>(prop2, v -> {
        if (Strings.isNullOrEmpty(v)) {
            return ValidationMessage.error("msg");
        }
        return null;
    });
    final CompositeValidator compositeValidator = new CompositeValidator(notEmpty1, notEmpty2);
    prop1.set("");
    prop2.set("");
    prop1.set("a");
    assertThat(notEmpty1.getValidationStatus().isValid()).isTrue();
    assertThat(notEmpty2.getValidationStatus().isValid()).isFalse();
    assertThat(compositeValidator.getValidationStatus().isValid()).isFalse();
}
@manuel-mauky
Copy link
Collaborator

I can reproduce this issue. I will take a deeper look into this tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants