question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different behavior of [Test]Validate on Unit Tests

See original GitHub issue

FluentValidation version

10.1.0

ASP.NET version

3.1

Summary

image

So on 9.5.4 I was getting IsValid == false, which is the expected result. I’m setting up nested validator to have errors. Now on 10.1.0 those errors don’t came back to parent validator / Validate.

Steps to Reproduce

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
flavio-cadete-ckocommented, May 13, 2021

Awesome thanks. It’s working

0reactions
JeremySkinnercommented, May 13, 2021

It’ll be something like:

validator.Setup(m => m.Validate(It.IsAny<ValidationContext<Document>>()))
	.Callback((ValidationContext<Document> context) => 
	{
		context.AddFailure(new ValidationFailure("Property", "ErrorMessage"));
	});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Test Extensions — FluentValidation documentation
You can use the TestValidate extension method to invoke a validator for testing purposes, and then perform assertions against the result.
Read more >
Unit Testing Fluent Validations
Fluent Validations is a popular package for doing those data validations. This tip is how to unit test those data validation behaviors.
Read more >
Fluent Validation – Unit Testing the Validators
In this article, we are going to have a look at how to unit test the validation logic written using fluent validation.
Read more >
Unit testing FluentValidation rules for classes with sub/child ...
Is it possible to write unit tests for fluentvalidation classes when the object we are validating has child classes that are also being ......
Read more >
FluentValidation.Validators.UnitTestExtension
Small library that extends and simplifies possibilities of testing code that is using FluentValidation package. - GitHub - MichalJankowskii/FluentValidation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found