Guest User

Untitled

a guest
Oct 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. public class MyModel : IValidatableObject
  2. {
  3. [Key]
  4. public int Id { get; set; }
  5.  
  6. public int Item1 { get; set; }
  7.  
  8. public int Item2 { get; set; }
  9.  
  10. public int Item3 { get; set; }
  11.  
  12. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  13. {
  14. if (Item3 < Item1 + Item2)
  15. {
  16. yield return new ValidationResult("Item1 + Item2 must be less than Item3", new List<string> { "Item3" });
  17. }
  18. }
  19. }
Add Comment
Please, Sign In to add comment