FluentValidation
FluentValidation copied to clipboard
[Question] <ValidationMessage For="..."> when validating the whole object using Must
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 <ValidationMessage For="myobject">, 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 <ValidationMessage/> component. Do I need to create another property in my class that the ValidationMessage can use?
Thanks
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().