I have a edited a fluent validation rulefor within Validators/Common/AddressValidator.cs.
I changed the base nop code from:
if (addressSettings.ZipPostalCodeRequired && addressSettings.ZipPostalCodeEnabled)
{
RuleFor(x => x.ZipPostalCode).NotEmpty().WithMessage(localizationService.GetResource("Account.Fields.ZipPostalCode.Required"));
}
To:
if (addressSettings.ZipPostalCodeRequired && addressSettings.ZipPostalCodeEnabled)
{
RuleFor(x => x.ZipPostalCode).NotEmpty().WithMessage(localizationService.GetResource("Account.Fields.ZipPostalCode.Required")).When(x=>x.ZipPostalCodeRequired);
}
By adding
.When(x=>x.ZipPostalCodeRequired);as described on your documentation HERE.
This results in no validation, even though the condition is met. I've tried all fluent validation validators chaining from .NotEmpty() and none of them work.
Is this a bug?