Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enterprise Library validation blocks

I've just started using the ms validation blocks which i think are awesome. but have a couple of questions regarding data validation between layers.

Currently I'm using the repository pattern as a bridge to my data access layer. In my logic layer I'm populating my business object and then validating using the validation block before passing it on to my repository layer which in turn passes it on to the data access layer for insertion. Should i validate it again in the repository? If so do i validate using the block again or is there a better way to do it at this level?

like image 200
Richard Banks Avatar asked Feb 02 '11 17:02

Richard Banks


1 Answers

As long as you are using a layered architecture where all calls to the repository go through the business layer you do not have to validate it again in the repository.

However, if the repository is being used by other systems that do not go via your business layer, you would need to validate it in the repository layer.

But, that would actually break the DRY Do Not Repeat Yourself principle.

Therefore, if you need to validate in the repository, you should not also do it in the business layer.

like image 159
Shiraz Bhaiji Avatar answered Sep 27 '22 16:09

Shiraz Bhaiji