Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Linq;
  5. using System.Web;
  6.  
  7. namespace Form1.Models
  8. {
  9. public class CostValidator : ValidationAttribute
  10. {
  11. protected override ValidationResult IsValid(object value, ValidationContext validationContext)
  12. {
  13. var pizza = (Pizza)validationContext.ObjectInstance;
  14. var cost = pizza.Cost;
  15. return cost < 11 ? new ValidationResult("cena musi być większa niż 10zł") : ValidationResult.Success;
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement