Spring - How to remove a `FieldError` from a BindingResult?
java, spring
Solution
Well, first of all, BindingResult is an interface, not a concrete class, and the interface doesn't specify any way to remove an error.
Depending on which implementation of the interface you are dealing with, there may be a method (beyond what's specified in the BindingResult interface) to do this, but it seems unlikely.
The only thing that I can think of is to create a new BindingResult instance, then loop through the errors and re-create all but the one that you want to ignore in the new one.
Problem
I have a `BindingResult result` that has a `FieldError` registered for the field `date`. How can I remove this error? Assume the error was added as `result.rejectValue("date", "my_code", "my_message") ;` Thanks in advance