tags:

views:

57

answers:

1

Can I use IDataError and service layer validation together?

I am using IDataError for my my model. However, I need to check for a condition in my service layer. If the condition is not true I need to give the user a validation message so that user can input new values.

Is this possible? Anything I need to take care of when attempting this?

A: 

Its possible but not recommended. Validation logic should be in one place DanaAnnotation implement this very well in such a way that server and client side validation is configured together. But As I said you can separate any part of validation in any layer you want but in this case if a business requirement change you should trace the change in any layer and as a result you end up with wasting time.

ali62b
but, what if the outcome is only known later.here is the scenario:1. check if all input data is valid2. do some processing with the data, but data not updated in database3. based on processing done in step 2, check some conditions4. if true proceed with database operations, else show errorWhat is the best practice to follow in this scenario?