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

Allow removal of error entries from Errors [SPR-14251] #18824

Closed
spring-projects-issues opened this issue May 5, 2016 · 1 comment
Closed

Allow removal of error entries from Errors [SPR-14251] #18824

spring-projects-issues opened this issue May 5, 2016 · 1 comment
Labels
in: core status: bulk-closed

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 5, 2016

Cagatay Kalan opened SPR-14251 and commented

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

@spring-projects-issues spring-projects-issues added status: waiting-for-triage type: enhancement in: core and removed type: enhancement labels Jan 11, 2019
@rstoyanchev rstoyanchev added status: bulk-closed and removed status: waiting-for-triage labels Jan 11, 2019
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 12, 2019

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: bulk-closed
Projects
None yet
Development

No branches or pull requests

2 participants