ASP.NET MVC 2 Model object validation
Posted
by
Jimmy
on Stack Overflow
See other posts from Stack Overflow
or by Jimmy
Published on 2011-01-10T15:14:14Z
Indexed on
2011/01/11
11:53 UTC
Read the original article
Hit count: 181
asp.net-mvc-2
|validation
Hey guys,
I'm trying to validate a model object outside of the context of ModelState within a controller, I currently have a parser that creates model objects from an excel file and I want to be able to report how many entries were added to the database and how many failed, is there a way to validate a model object on its data annotations outside of model binding?
I'm looking for something similar to the rails model method of model.valid?
or a way for me to implement that myself.
My current solution is just manually checking if a few key fields are present but this duplicates requirements between my model class and its metadata, there has to be a better way to hook into the model validation checking that is done by mvc 2.
Thanks
© Stack Overflow or respective owner