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

The collection validator is ignored in a nested validator #90

Closed
sdobrovolschi opened this issue Oct 9, 2020 · 0 comments · Fixed by #91
Closed

The collection validator is ignored in a nested validator #90

sdobrovolschi opened this issue Oct 9, 2020 · 0 comments · Fixed by #91
Labels
bug Something isn't working

Comments

@sdobrovolschi
Copy link
Contributor

Given the following class hierarchy

class Root {
   Parent parent;
}

class Parent {
   List<Child> children;
}

class Child {
   String name;
}

The validation of children is ignored.

var childValidator = ValidatorBuilder.of(Chidl.class)
                    .constraint(Child::getName, "name", Constraint::notNull)
                    .build();

var parentValidator = ValidatorBuilder.of(Parent.class)
                    .forEach(Parent::getChildrent, "children", childValidator)
                    .build();

var validator = ValidatorBuilder.of(Root.class)
                    .nest(Root::getParent, "parent", parentValidator)
                    .build()

The issue is that nested collection validators are not appended to the main validator. Please see https://github.com/making/yavi/blob/develop/src/main/java/am/ik/yavi/builder/ValidatorBuilder.java#L694

@making making added the bug Something isn't working label Oct 15, 2020
making added a commit that referenced this issue Nov 26, 2020
closes gh-90

Co-authored-by: sdobrovolschi <sdobrovolschi@usenergysolutions.us>
Co-authored-by: Toshiaki Maki <tmaki@pivotal.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants