How to remove a single error from a property with multiple validation
问题 In my ViewModel I have a property with multiple validation errors like this [Required(ErrorMessage = "Required")] [RegularExpression(@"^(\d{1,2})$", ErrorMessage = "Only numbers admitted")] [MaxLength(3, ErrorMessage = "MaxLength is 3")] public string MyField { get; set; } The "Required" validation depends on user input on another field, so in the controller I want to remove the error from the ModelState. The only way to do it that I found is like this: if (view.OtherField != null && view