I have a form field that should be converted to a Date object, as follows:
And I have requirement to mak
There is a way to do this if you'll move from Spring MVC validators to Hibernate. It's not a big deal because Hibernate validators work well with Spring Validator interface (also you may be interested in SmartValidator intreface which supports groups).
After that you can specify
@NotNull
annotation on the date field.
In properties file just add
NotNull.[formName].[dateField]=This message will be displayed if no date sent
typeMismatch.[formName].[dateField]=This message will be displayed if spring was not able to convert input to date object (format validation error)
For format check you can use CustomDateEditor.
With this solution you will get expected validation error messages in each case you've specified.