Skip to content

@MVC should provide an "onBind" hook prior to automatic validation [SPR-6437] #11103

@spring-projects-issues

Description

@spring-projects-issues

Sam Brannen opened SPR-6437 and commented

When using @Valid to drive automatic validation of a model object, it is currently not possible to modify the bound model object prior to validation.

With the SimpleFormController hierarchy it was straightforward to override BaseCommandController's onBind() or onBindAndValidate() methods to achieve custom binding; however, with @MVC it is currently not possible. Neither the WebBindingInitializer API nor an @InitBinder method provides a mechanism to plug in custom binding.

Note that this was not an issue prior to support for @Valid, since without @Valid developers were responsible for executing validation code within a handler method.

One possible solution would be to add support for an @PostBinding method or @PreValidation method (or similar) which would be allowed to modify the model after binding but prior to executing the handler method.


Affects: 3.0 RC2

Issue Links:

6 votes, 6 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions