Closed
Description
FluentValidation version
11.0.2
ASP.NET version
No response
Summary
Wrapping a call to RuleForEach
with WhenAsync
will trigger a AsyncValidatorInvokedSynchronouslyException
even when calling ValidateAsync
.
The AsyncValidatorInvokedSynchronouslyException
should only be thrown when calling Validate
, never ValidateAsync
.
Steps to Reproduce
class MyValidator : AbstractValidator<Person> {
public MyValidator() {
WhenAsync((x, cancel) => x.Id > 0, () => {
RuleForEach(x => x.Nicknames).NotNull();
});
}
}
class Person {
public int Id { get; set; }
public string[] Nicknames { get; set; }
}
var validator = new MyValidator();
await validator.ValidateAsync(new Person());
// Incorrectly throws a AsyncValidatorInvokedSynchronouslyException even though it was invoked asynchronously.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
JeremySkinner commentedon Jun 10, 2022
Fixed in 11.0.3