ASP.NET MVC 2 Model object validation
- by Jimmy
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