Say I have a model that's annotated with [Required] fields etc in an MVC application.
It works great in the controller to just call ModelState.IsValid but say I'm not in the controller and would like to run similar checks elsewhere in my application on the model. Is it possible to somehow call this functionality another way?
class MyModel{
[Required]
public string Name{get;set;}
}
// Code elsewhere in app that isn't the controller
MyModel model = new MyModel();
//Can I run a modelstate.isvalid type check here on model? Would return false if Name wasn't set