I understand that Spring Validator is widely used, and as an application I'm currently working on already uses Spring, it seems the right way to go when validating class details.
My Service layer is going to be validating objects, using the appropriate implementation of Validator
.
The best way of then dealing with these errors, as I can see, is throwing my own exception within the Service layer - so that transactions are rolled back and the exception can be caught and handled by my UI layer.
Question is - why pass this Errors object around at all? As Java deals with exceptions naturally, I'd have thought throwing an appropriate Exception (perhaps with all error details) would be performed?
Relatively new to this, so any input greatly appreciated.