-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async schema validation support #159
Conversation
The test module changes in the PR look like they check 'test succeeds unexpectedly' only if the validation throws instead of if it succeeds. Further, texts involving the success and fail of a genuine async schema are needed. I don't think I should review such a sensitive code change without first knowing that it looks like it works. I can look at this further once the tests are improved. |
Return Promise only if schema contains $async prop
Oh, ok, sorry. Changed the schemas validation to less general, but backwards compatible way. Schema is considered async if it contains "$async: true" property, and in this case validateSchema returns promise. Otherwise schema validated in same way as before. |
I think that's a good way to go. I review as soon as I can. |
@beeplin Would you mind commenting on this issue and code? Thanks. |
didn't check details about the errors handling, but according to the new test, it should be working fine. And this new feature is definitely a must-have. :) |
This will be published with v3.2.1. |
Summary
This PR aims to add support of asynchronous schema validation. Example of async schema:
Example from https://runkit.com/esp/ajv-asynchronous-validation
Other Information
I guess potentially it could break something, because tests were written in synchronous try-catch way. But Feathers.js executes hooks in async manner, so this should be fine 🤔