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.

TestHelper.ShouldHaveValidationErrorFor.WithoutErrorCode broken in 11.0

See original GitHub issue

FluentValidation version

11.0

ASP.NET version

No response

Summary

When adding multiple validation rules the TestHelper’s ShouldHaveValidationErrorFor.WithoutErrorCode throws for each and any specified error code (see MWE below). The issue was introduced by d4773d2, but I’m not yet(?) powerful enough to suggest a fix.

Steps to Reproduce

namespace FluentValidation.Tests {

	using Xunit;
	using FluentValidation.TestHelper;
	public class WithoutErrorCodeIssue_Reproduce {

		class A {
			public A() { s = ""; }
			public double d = 0;
			public string s;
		}

		class AV : AbstractValidator<A> {
			public AV() {
				RuleFor(a => a.d).InclusiveBetween(1, 3); // remove this line this line to make the test pass
				RuleFor(a => a.s).NotEmpty();
			}
		}

		[Fact]
		public void Reproduce() {
			var vld = new AV();
			var res = vld.TestValidate(new A());

			res.ShouldHaveValidationErrorFor(a => a.s).WithoutErrorCode("abc");
		}
	}
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
JeremySkinnercommented, May 7, 2022

I’ve pushed out 11.0.1 to nuget with the fix. Thanks @Aleksei-Pankratev-EPAM for your work on this

1reaction
Aleksei-Pankratev-EPAMcommented, May 7, 2022

Thank you @akamud! Now this is fixed too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test Extensions — FluentValidation documentation
FluentValidation provides some extensions that can aid with testing your validator classes. We recommend treating validators as 'black boxes' - provide ...
Read more >
FluentValidation ShouldHaveValidationErrorFor with ...
I'm using the FluentValidation library in an ASP.NET MVC project and, from a UI perspective, it's working as expected. Rule violations display ...
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