0

I have object that I want to validate using Spring Validator.

public record MyRequest(
List<@Valid Item> items,
//  ...
)

and Item:

public record Item(
String foo,
//  ...
)

Then I want to indicate that the third item has an invalid foo value.

I tried to use errors.rejectValue method with items[2].foo as fieldValue, but I get the following error:

Cannot retrieve value for field 'items[2].foo' - neither a getter method nor a raw field found
1
  • I think @Valid should be added to the controller level Commented Nov 2 at 16:11

0

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.