TestHelper.ShouldHaveValidationErrorFor.WithoutErrorCode broken in 11.0
See original GitHub issueFluentValidation 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:
- Created a year ago
- Comments:10 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve pushed out 11.0.1 to nuget with the fix. Thanks @Aleksei-Pankratev-EPAM for your work on this
Thank you @akamud! Now this is fixed too.