I guess this behaviour is not covered in the documentation well.
The problem is caused by the following:
-
By default,
@InitBinder-annotated method is called for each non-primitive model attribute, both incoming and outcoming (the purpose of calling it for outcoming attibutes is to allow you to register customPropertyEditors, which are used by form tags when rendering a form). -
DataBinder.setValidator()contains a defensive check that callValidator.supports()and throws an exception iffalseis returned. So, there is no attempt to perform a validation, just an early check.
The solution is to restrict the scope of @InitBinder to particular attribute:
@InitBinder("whaleFormData")
protected void initBinder(WebDataBinder binder) { ... }