Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Web;
- namespace Form1.Models
- {
- public class CostValidator : ValidationAttribute
- {
- protected override ValidationResult IsValid(object value, ValidationContext validationContext)
- {
- var pizza = (Pizza)validationContext.ObjectInstance;
- var cost = pizza.Cost;
- return cost < 11 ? new ValidationResult("cena musi być większa niż 10zł") : ValidationResult.Success;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement