国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Fluent Validation For .NET

2019-11-17 01:47:00
字體:
來源:轉載
供稿:網友

Fluent Validation For .NET

//.net 中數據驗證,一個開源的項目,直接下載 1 using FluentValidation; 2  3 public class CustomerValidator: AbstractValidator<Customer> { 4   public CustomerValidator() { 5     RuleFor(customer => customer.Surname).NotEmpty(); 6     RuleFor(customer => customer.Forename).NotEmpty().WithMessage("Please specify a first name"); 7     RuleFor(customer => customer.Discount).NotEqual(0).When(customer => customer.HasDiscount); 8     RuleFor(customer => customer.Address).Length(20, 250); 9     RuleFor(customer => customer.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode");10   }11 12   PRivate bool BeAValidPostcode(string postcode) {13     // custom postcode validating logic goes here14   }15 }16 17 Customer customer = new Customer();18 CustomerValidator validator = new CustomerValidator();19 ValidationResult results = validator.Validate(customer);20 21 bool validationSucceeded = results.IsValid;22 IList<ValidationFailure> failures = results.Errors;


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泰来县| 平罗县| 淮南市| 庐江县| 新绛县| 格尔木市| 德兴市| 资溪县| 郯城县| 六枝特区| 云霄县| 锦屏县| 惠安县| 高青县| 宜宾市| 基隆市| 岚皋县| 庆元县| 锦屏县| 南岸区| 丰镇市| 陕西省| 定结县| 开阳县| 铁岭县| 光泽县| 绩溪县| 化德县| 深州市| 长乐市| 恩施市| 都江堰市| 汽车| 光山县| 栾川县| 新乡市| 长宁县| 天津市| 额济纳旗| 普格县| 淮阳县|