Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Well said, documnetation for Spring Web Flux functioal is just great as compared to controller
style. But it keeps silence on saying how to perform validation with Functional Style.
Either we should have documentation improvement mentioning how validation will be done
with functional style or we should have dedicate support for it.
Affects: 5.0.10, 5.1 GA, 5.1.1
Referenced from: commits 15f8863
1 votes, 3 watchers
Hi! I'm a Baeldung author, and I've worked on an article related to this topic:
In there I show readers how they can implement Spring validations with a simple, clean and DRY approach.
In a nutshell, I suggest the following steps to run validations in functional endpoints:
I'm thinking it would be nice for Spring to provide an AbstractValidationHandler out-of-the-box for users to use when they need to run validations in their endpoints.
Even though there are probably several aspects on the abstract class that should be refactored so as to be suitable for any scenario, I think it might be a good starting point.
Note: As I explain in the post, creating custom validators can be omitted since we can add bean validation annotations to our resource and inject the default Spring Validator provided by the LocalValidatorFactoryBean bean to our handler.
Of course, if we decide that such a class would be in fact useful, I'd like to work on its development myself, if that's possible.
Rossen Stoyanchev commented
rozagerardo thanks for the link to the article. The base class isn't providing enough value IMO to justify the rigidity of having to extend a base class. Delegation should work just as well and let you extend any class you want. In any case such a change is beyond the scope for the request.
Ankur Pathak, in the functional style you get the body object back and it's up to you to validate it. You can use facilities available in the Spring Framework to do that, as shown in the article by rozagerardo.
I guess what we can do in the docs is to provide brief guidance on this with pointers to relevant information.