0

Can I override modelbinding process for certain model in order to change the way validators are searched for model and properties?

I want to apply validators conditionally depending on some parameter passed into model binder from request context.

I wondering If this is possible at all?

drunkcamel
  • 915
  • 3
  • 12
  • 25
  • _the way validators are searched for model and properties_ what does that mean? –  Mar 28 '15 at 19:25
  • @gerdi I think, by default validators are searched just by metadata/attributes by I want to filter validators by a given condition to eventually apply only some of them. Is it possible? – drunkcamel Mar 28 '15 at 20:30
  • this might be what you are looking for http://stackoverflow.com/questions/16100300/asp-net-mvc-custom-validation-by-dataannotation –  Mar 28 '15 at 20:43
  • Consider using custom validation attributes such as `[RequiredIf]` so that you get both client side and server side validation based on other properties in your model. –  Mar 28 '15 at 22:59
  • @stephen-muecke [RequiredIf] won't work since I have nested complex model. Therefore I'm trying to get to the point from the other side. Override validators providers or binders or whatever else to inject my condition when getting some particullar attributes to prevent some validation from being run based on incomming Form param which can be get from ControllerContext.RequestContext. Please, advise. – drunkcamel Mar 29 '15 at 17:16

0 Answers0