Login
C# - pattern matching - many discards
8115 просмотров
Перейти к просмотру всей ветки
AlexNek патриот
in Antwort Отпускник 21.02.24 18:57, Zuletzt geändert 21.02.24 19:45 (AlexNek)
ну так написал же... Пишешь просто набор правил
RuleFor(x => x.Surname).NotEmpty(); RuleFor(x => x.Forename).NotEmpty().WithMessage("Please specify a first name"); RuleFor(x => x.Discount).NotEqual(0).When(x => x.HasDiscount); RuleFor(x => x.Address).Length(20, 250); RuleFor(x => x.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode");
RuleFor(x => x.Name).NotEmpty().WithMessage("name cannot be null");
RuleFor(x => x.Phone).NotEmpty();
RuleFor(x => x.Other).GreaterThan(0).WithMessage("other must be great than 0");;