Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net mvc different validation rules for different actions

What is the best practice for validating my model for different actions, for example, different validation rules for creating and deleting?

Thanks!

Clarification: I think this needs some clarification because the answers don't seem to be addressing the question.

For example,

Create Person Validates that has name, age and email is not in use Delete Person Validates that the Person isn't a Parent. Business logic dictates that Parents can't be eliminated

How do I have these two different validation scenarios?

like image 682
user10479 Avatar asked Oct 14 '22 13:10

user10479


1 Answers

As i understand you want more control on your validation rules. You can manually add validation rules as described here: MVC 2.0 Client validation exposed This gives you full control on how to organize you validation, which rule add on which action, etc.

like image 104
Hennadiy Kurabko Avatar answered Oct 19 '22 07:10

Hennadiy Kurabko