-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Milestone
Description
FluentValidation version
11.1.1
ASP.NET version
No response
Summary
I have old working code which uses MemberNameValidatorSelector to validate particular property path from the entity. In any version higher than 11.1.0 code stops working without any messages or exceptions. Error is not generate when expected.
Might be that MemberNameValidatorSelector utilization is not correct from the begging. It's taken from some samples time ago.
Steps to Reproduce
Please, see working dotnetfiddle example https://dotnetfiddle.net/5o03Fy
Simply downgrade FluentValidation version to 11.1.0 to get correct results.
Thanks!
var validator = new RulesetChildValidatorRulesValidator();
var validatorSelector = new MemberNameValidatorSelector(new[] { "Orders.Quantity" });
var person = new Person
{
Orders = new List<Order>
{
new() { Quantity = 0 }
}
};
var fluentValidationContext =
new ValidationContext<Person>(
instanceToValidate: person,
propertyChain: new PropertyChain(),
validatorSelector: validatorSelector
);
ValidationResult result = await validator.ValidateAsync(fluentValidationContext);
//ERROR is Expected here
private class RulesetChildValidatorRulesValidator : AbstractValidator<Person> {
public RulesetChildValidatorRulesValidator() {
RuleFor(x => x.Surname).NotEmpty();
RuleForEach(x => x.Orders).ChildRules(x => {
x.RuleFor(y => y.Quantity).GreaterThan(0);
});
}
}
Metadata
Metadata
Assignees
Labels
No labels