1

Hi I have the next code:

public class PkData{
    @NotNull
    Private String stringA;
    ...
}

public class A{
    private PkData pkData = new PkData();

    @NotNull
    private Integer sequenceNumberA;

    @NotNull
    Private String stringA;

    @NotNull
    Private String stringB;
...
}

public class B{
    @NotNull
    private A a;
...
}

When call Set<ConstraintViolation<User>> violations = validator.validate(B);

The validator only return B errors, and not sub clases errors like A.stringA as not null.

How can do get these validations.

And if B be a B[] how can do it?

Any idea? thanks

1
  • It really really is unclear what you are talking about. Please consider rewriting the question. Commented Jan 23, 2019 at 15:10

2 Answers 2

1

You need to put @Validannotation on private A a; in class B

Sign up to request clarification or add additional context in comments.

Comments

1

You can create validate methods in each Class A and class PkData which will check the value of each private fields present in them and validate those values.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.