Muhammad Adeel Zahid
Muhammad Adeel Zahid

Reputation: 17784

Model vs Input Validation for MVC 2 .NET

MVC 2 comes with built-in support of Model validation but how do I do "input validation"? For example I have an interface of creating memo where I have populated the view with dynamic checkboxes corresponding to employees. The validation is straight forward i.e do not submit if no checkbox is selected.

I wonder if there is a way of doing such things in DataAnnotations. I have searched the internet and found that people have written a lot of code to validate password and confirm password validation just for the sake of doing it the nicer way.

My question is if there is a nicer way for my problem or should I just count number of checkboxes in my controller action and return error if no checkbox is selected?

Upvotes: 1

Views: 284

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038770

I would recommend you looking at the FluentValidation library which integrates nicely with ASP.NET MVC.

Upvotes: 1

Related Questions