Blazored / FluentValidation

A library for using FluentValidation with Blazor
https://blazored.github.io/FluentValidation/
MIT License
597 stars 85 forks source link

[Question] <ValidationMessage For="..."> when validating the whole object using Must #203

Open abbottmw opened 11 months ago

abbottmw commented 11 months ago

I have a complex validation so I am using the Must() method on the FluentValidation call. This may have an easy answer, but when I use , the error messages above each question do not show up. Is there a way to make the ValidationMessage component work with a whole object and not a property?

I have a Rule like

RuleFor( r => r).Must(ValidateObject).WithMessage("custom error messsage");

but not sure how to get that message to show up using the component. Do I need to create another property in my class that the ValidationMessage can use?

Thanks

abbottmw commented 10 months ago

So, I got the validation to work restructuring how I setup the validations. Chained some When() calls to handle the different kinds of validation based on a property. I started creating dependant rules, but changed those to When().