Blazor sever-side, .NET7, using Nuget package Blazored.FluentValidation version 2.1.0
I have a model that includes two bool properties IsAdmin and Agreed. The first is for internal use (to skip certain checks when the logged-in user is an admin) and the second is to say the user has accepted the terms and conditions before submitting the form.
I want a validation rule that checks that Agreed is true when IsAdmin is false. I tried the following...
RuleFor(p => p.Agreed) .Equals(true) .When(p => !p.Admin) .WithMessage("You must accept the terms and conditions");...but got a compiler error on When...
Cannot resolve symbol When
I'm not sure what I've done wrong, as I've used When in other places without problem, eg...
RuleFor(p => p.SelectedTimePackageId) .GreaterThan(0) .When(p => p.SelectedPrintPackageId == 0) .WithMessage("You must select a time package and/or a print package");I know I can get around this with a custom validation rule, but would like to know why When isn't resolved.