One way to solve this to define a custom parameter in your message: {0}
. So your the message would look like this in your resource file.
'{PropertyName}' and '{0}' fields do not match.
And pass in the "ConfirmEmail"
as an extra argument to the WithLocalizedMessage
call:
RuleFor(a => a.Email)
.Equal(a => a.ConfirmEmail)
.WithLocalizedMessage(() => MyResource.compareFields, "ConfirmEmail");