c# - Add Required to a model depending on the value of another property? -


this question has answer here:

i have field in model looks this

[display(name = "companytype", resourcetype = typeof(captions), autogeneratefilter = true)] [lookup(lookuptextfield = "typefordisplay", lookupentity = "type", lookupcolumns = new[] { "typefordisplay" }, lookuptype = lookuptype.dropdown)] public guid? typeid{ get; set; } 

i want add required property, not in casses. depends on value of property in model. best(easiest) way this?

you can create custom validator accomplish this.

here tutorial on how go it.


Comments