-
Notifications
You must be signed in to change notification settings - Fork 20
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
Bugfix/js/deep nested arrays #13
Conversation
… nested array as flat array
…ted field use testValueOrArray with within(), reorder array check conditions
…s with deeply nested array
Looks very good at first sight! Thank you very much! I'll do a closer look tomorrow morning, today is a bit busy |
This PR introduce a bug with the it('checks that at least one item from projected array satisfies condition', () => {
const condition = new Field('size', 'items.a', 2)
expect(interpret(condition, { items: [{ a: [2, 3] }, { a: [] }, {}] })).to.be.true
expect(interpret(condition, { items: [5, 4] })).to.be.false
expect(interpret(condition, { items: { a: [2, 3] } })).to.be.true
expect(interpret(condition, { items: [{ a: [2, 3] }, { a: [4] }, {}] })).to.be.true
// --> return false because the value is [2,3,4] and not [[2,3], [4]]
}) |
I’ll check how MongoDB works in case of checking size for deeply nested array props |
…and array of arrays
I fixed the issue. Thanks for pointing out! |
available in @ucast/js@2.2.1 |
Great! |
It modify the
getField
function in order to works with deeply nested arrays of objects and output a flat array of items.This also helps interpreters to validate items without having to loop through nested arrays.
It removes the
PROJECTED_FIELD
const and its export as it's not needed anymore.And it refactor the
within
interpreter by usingtestValueOrArray
, thesize
one by removing the projected_field check and theall
one by reordering the array check.It also adds tests to be sure that getting and checking deeply nested arrays of objects works.