validationattribute

RequiredIf Conditional Validation Attribute

你。 提交于 2019-11-26 01:27:45
问题 I was looking for some advice on the best way to go about implementing a validation attribute that does the following. Model public class MyInputModel { [Required] public int Id {get;set;} public string MyProperty1 {get;set;} public string MyProperty2 {get;set;} public bool MyProperty3 {get;set;} } I want to have atleast prop1 prop2 prop3 with a value and if prop3 is the only value filled it it should not equal false. How would i go about writing a validation attribute(s?) for this? Thanks