Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyModel : IValidatableObject
- {
- [Key]
- public int Id { get; set; }
- public int Item1 { get; set; }
- public int Item2 { get; set; }
- public int Item3 { get; set; }
- public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
- {
- if (Item3 < Item1 + Item2)
- {
- yield return new ValidationResult("Item1 + Item2 must be less than Item3", new List<string> { "Item3" });
- }
- }
- }
Add Comment
Please, Sign In to add comment