I'm using spring-boot based rest services and looking to apply a default validation on all strings.
- I want to apply a default validation on any string field that is part of a @RequestBody or @Param. Note: I need a default validation, i.e. I want to be able to do it without annotating all string fields.
- I want to be able to annotate a field to skip validation.
- I plan to implement this using a Controller advice so that all controllers get this validation.
I have looked into using property source editors but that doesn't look like it's designed to throw validation errors from there. I'm not sure if I'll have access to applied annotations on the field either.
Using a Custom spring Validator implementation, I'm not sure how I can handle nested fields in a complex object.
I'm pretty sure I'm not the only one looking for an answer for something like this. Is there a recommendation?