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.

Validators should throw an exception when async rules are executed synchronously

See original GitHub issue

At the moment if a validator contains async rules and is executed with Validate, all the rules will be silently be executed synchronously instead. This is not good behaviour.

2 Options:

  1. Change the default behaviour for 9.0 so that this generates an exception, forcing ValidateAsync to be called instead. This should be an opt-out behaviour so the current behaviour can be maintained (controllable by a switch which should generate a warning). This is the easiest change, but generates a runtime error which is non-obvious.

  2. Remove all async methods from AbstractValidator, and instead have an explicit AsyncAbstractValidator. This is a very large piece of work, and is a bigger breaking change for users too. But this will be a compile time error, so much easier to spot.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Dec 10, 2019

Moving this out of the 9.0 release.

0reactions
JeremySkinnercommented, Aug 9, 2020

Superceded by #1481

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asynchronous Validation — FluentValidation documentation
Calling ValidateAsync will run both synchronous and asynchronous rules. Warning ... If you call Validate , then an exception will be thrown.
Read more >
Should an async API ever throw synchronously?
How important is it that an async function should always behave in an async manner, particularly for error conditions? Is it OK to...
Read more >
Parameter validation in "async"/"await" methods should be ...
Because of the way async/await methods are rewritten by the compiler, any exceptions thrown during the parameters check will happen only when the...
Read more >
Documentation: DevExtreme - JavaScript Validator Async Rule
Validation rules are checked in the following order: All the synchronous rules are ... If true, the validationCallback is not executed for null,...
Read more >
Asynchronous validation
If asynchronous format/keyword or reference to asynchronous schema is used in the schema without $async keyword Ajv will throw an exception during schema ......
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