org.springframework.validation.Errors interface and none of the implementations allow removal of binding or validation errors however in real life scenarios, it is a common requirement especially for conditional validation requirements.
Conditionally validating an object or a web request is more difficult then first validating it completely and then removing some specific field errors based on the condition. The former requires partial binding and validation ( manually ) but the latter only requires some basic if checks. Also, manual execution of binding and validation requires injection of a databinder, and prevents using automatic binding and validation support of request mapping handler method arguments in mvc scenarios.
As an example, imagine you have a registration form where a radio button decides if the account will be a personal or a corporate account. Based on this condition, for personal account, birthday will be required, and for corporate account, tax id will be required. If we can remove errors from the BindingResult, we can just put a model object and a BindingResult argument to a request mapping handler method and then remove specific errors based on the "accountType" property's bound value.
Currently the only way to do this is to create another Errors or BindingResult object and copy specific errors to this new object which is ugly while supporting this feature in AbstractErrors seems to be pretty trivial.
Affects: 4.3 RC1
The text was updated successfully, but these errors were encountered: