### CustomerValidator with AbstractValidator and RuleFor Source: https://fluentvalidation.net Shows a complete validator class that defines rules for a Customer object, including NotEmpty, WithMessage, When, Length, and Must with a custom postcode check. The BeAValidPostcode method is a placeholder for custom logic. ```csharp public class CustomerValidator : AbstractValidator { public CustomerValidator() { 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"); } private bool BeAValidPostcode(string postcode) { // custom postcode validating logic goes here } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.