Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abbottmw opened this issue Dec 4, 2023 · 1 comment
Labels
Question Question about this project Triage Issue needs to be triaged

Comments

@abbottmw
Copy link

abbottmw commented Dec 4, 2023

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 abbottmw added Question Question about this project Triage Issue needs to be triaged labels Dec 4, 2023
@abbottmw
Copy link
Author

abbottmw commented Jan 9, 2024

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Question about this project Triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant