Re: Validating a collection in business layer: best practices
I do not believe the Business Layer should be responsible for validation. In my framework, I have a class that us used strictly for common validation purposes (valid email address, web address, ect...). I would suggest you create a separate class for your validation thus creating a more decoupled code (you never know when it will be used again).
As for what to do when your collection is not valid, I would simply print out an error. I use exceptions when there could be errors PHP cannot recover from. This provides an elegant way to exit the application. A invalid object can easily be handled by you, without exiting the application.
|