0

I tried in this way but this doesn´t work properly:

RuleForEach(p => p.Childs).NotEmpty().ChildRules(child =>
        {
            child.RuleFor(p => p.Name).NotEmpty();
            When(p => p.Child2.Name == "cool", () =>
            {
                child.When(c => c.Code < 56, () =>
                {
                    RuleFor(p => p.Surname).NotEmpty();
                    When(p => p.Date.HasValue, () =>
                    {
                        RuleFor(p => p.Total).InclusiveBetween(4, 6);
                    });
                });
            });
        });

Could anyone helps me? Thx

pelotu2
  • 35
  • 5
  • I think the InlineValidator inherits from AbstractValidator this .When() function but this only works in AbstractValidator and not in InlineValidator. I put a breakpoint inside predicate (first param of When() func) and it didn´t hit!! But action content (second param of When() func) hit properly. Perhaps the documentation is ambiguous. – pelotu2 Mar 17 '22 at 16:20
  • Please include the code of models being validated. – Prolog Apr 29 '22 at 06:41

0 Answers0