I'm trying to validate an input parameter in the Controller with my custom validator and then use BindingResult to get validation results.
So I made ConstraintValidator and @interface "ValidatorCust" to call my own check. It runs like a charm with the model attributes. So its very convenient and concise to check errors with just binding result:
But now I'm stuck with how to check an input parameter in controller.
The check runs fine and my restriction works right, but in further its not works as expected: I'm getting javax.validation.ConstraintViolationException with correct check result and then applications stops without any ability to just check Binding result.
After lots of reading I figured out that I can use @ExceptionHandler to override this, but it is verbose and no so convenient comparing to BindingResult's check. Another way I guess is just instantiate ValidatorFactory, Validator and then explicitly do check inside a Controller's code (as I take, explicit using of Spring's validator here is almost the same).
The question: is there any way to use Binding Result with input parameter validation (without sticking to model)? And if its not, which way for me is the best?