-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fix oneof #435
Fix oneof #435
Conversation
Would this also be a fix for #112 ? |
yes, I believe it should be |
Is there any progress on this? Or something which I could contribute to? Having |
As far as I'm concerned it's done. I'm using this version in production. |
@aldeed Any chance this could be in the next release? |
What's the status of this one? |
Is there any chance to see this merged anytime soon? |
@aldeed Is there a reason why this isn't getting any attention? Is there a timeline we should be aware of that is delaying this? Seems like a bug/feature that has been requested a lot, and for a long time |
No status update at all... |
Thank you for your initial work on this @znewsham. I took your tests and some of your ideas and implemented in a slightly different way in e8f91dc. The main difference is recursing within the already-existing multi-type list, and adding a loop through all possible definitions, which avoids needing to prebuild the 3.3.0 release |
Thanks @aldeed - I believe one of the reasons I went with the |
@znewsham No, but benchmarks would be interesting in general. This package is already quite slow because of needing to handle mongo modifiers. I've often thought of trying to split that feature out so that normal object validation can be made faster (i.e. no |
(replaces #431 - it was from the main branch which was causing trouble.)
This ended up being quite a lot larger than I initially planned. Initially it looked like it was going to be fairly simple, but alas not. All tests are passing and I added a handful of others.
I believe this fixes #428 and #410
There are a few small changes that look large, and a couple of actual large ones:
checkObj
- move everything after thevalidate
call into a new function calledrecurse
- this is called bycheckObj
in the case that we don't want to validate a key (or initially when we dont have a key) but also byvalidate
which may also change the "schema" used from the root schema to the current branch schema.def.type.some
completes with multiple options. At which point it either discards the entire array (in the case of a pass) or continues to concat.subSchema
subSchemaAffectedKey
andsubSchemaAffectedKeyGeneric
(sometimes) are now additionally passed around - these represent the current sub schema and the affected key relative to the sub schemaaffectedKey
andaffectedKeyGeneric
refer to the current key relative to the root schema.oneOfKeys()
andrecursiveKeys()
functions to accumulate all keys in a schema (including child schemas) and those that are inside of aoneOf
.checkModifier
to check if a key is inside aoneOf
and if so run the check against each subSchemaThanks for providing such a vast library of test cases - it made implementing this very safe. I'm going to include this in my project where I've been hacking around this limitation for ages, and will ensure that all my schemas work, as I make heavy use of
oneOf(schema1, schema2, ...)