-
Notifications
You must be signed in to change notification settings - Fork 91
fix(manager): allow multiple field listener validators #758
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add test cases?
registerField({name: 'field', validate: fn1})
registerField({name: 'field', validate: fn2})
- two sync validations - pass & fail
- two async validations - pass & fail
- combine sync and async - pass & fail
Codecov Report
@@ Coverage Diff @@
## state-manager #758 +/- ##
==============================================
Coverage 93.15% 93.16%
==============================================
Files 222 223 +1
Lines 3784 3804 +20
Branches 1182 1188 +6
==============================================
+ Hits 3525 3544 +19
- Misses 259 260 +1
Continue to review full report at Codecov.
|
cebf2ba
to
f4578c8
Compare
Validation can now correctly evaluate fields with multiple registered validators. Every validator is converted to promise, regardless if it is async or sync validator. This allows us to properly evaluate fields with multiple async validators. Sync validation order is preserved due to the sequential nature of the code execution and immediate promise resulution. One downside is that we have run tests with setImmediate to wait for the manager api state update. Benefit is, that we can have more than one async validator and can it does not have to be at the start of the validate array as it is right now in the renderer.
f4578c8
to
62aba51
Compare
@rvsia well turns out I had to re-do the whole validation process because there was an issue with concurrency. But we should have even more powerful validation support right now. We can have unlimited number of async validators with the all-new |
Won't be this too huge breaking change for all applications using DDF? |
@rvsia yeah it will. What we can do, is first run all the validators, check if there is an async validation and return a promise based on that. That is an option we probably should and could do. Async validation test must have async-await/setImmediate/timeout anyway. |
Yeah, sounds good. Run them and just compose async validators. Do you want to do it in this PR? |
Yes I will. In this PR |
@rvsia the compose validators will only return a promise if one or more validators are asynchronous. |
c3da8f3
to
2aac294
Compare
🎉 This PR is included in version 3.1.0 🎉 The release is available on Demo can be found here! |
part of #739
I have added
composeValidators
but then I have realized, it's not usable for this feature. I have not added test but we will need this function later anyway.