silvershop-core icon indicating copy to clipboard operation
silvershop-core copied to clipboard

Don't use ValidationExceptions for failing validation

Open jedateach opened this issue 9 years ago • 1 comments

Writing a module to allow customers to choose a delivery date, I noticed how we throw exceptions to fail validations. I now think that exceptions should be reserved for when things go wrong that are out of the system's control (such as service calls).

A better approach would be to update the ValidationResult object, and then respond to that result to get validation valid status, and corresponding messages.

For reference see the validateData method of any checkout component

jedateach avatar Sep 11 '15 04:09 jedateach

@jedateach did you end up with some code for choosing a delivery date? We are going to need that functionality in our current project, will try to write it as a generic module with options to block delivery dates.

thomasbnielsen avatar Feb 24 '16 20:02 thomasbnielsen