Skip to content

feat: Add contains_all, contains_any and contains_none operators - #59

Draft
iyk2h wants to merge 1 commit into
json-logic:masterfrom
iyk2h:feat/array-containment-operators
Draft

iyk2h wants to merge 1 commit into
json-logic:masterfrom
iyk2h:feat/array-containment-operators

Conversation

@iyk2h

@iyk2h iyk2h commented Aug 24, 2026

Copy link
Copy Markdown

Closes #58

Adds three array containment operators — contains_all, contains_any, contains_none — for array-to-array comparison, as proposed in #58.

Semantics

Rule Result
{"contains_all": [["a","b","c"], ["a","b"]]} true
{"contains_all": [["a","b","c"], []]} true (vacuous)
{"contains_any": [["a","b","c"], ["x","b"]]} true
{"contains_any": [["a","b","c"], []]} false
{"contains_none": [["a","b","c"], ["x","y"]]} true
{"contains_none": [["a","b","c"], []]} true (vacuous)

Implementation notes

  • Plain synchronous functions in defaultMethods.js, so they are automatically Sync and deterministic — they work unchanged across sync/async engines, inline/no-inline, and both optimizer modes.
  • New suite suites/comparison/contains.json (29 cases mirroring the Go test matrix plus var-resolution and missing-data cases) — picked up by compatible.test.js, giving 464 test executions across the 8 engine configurations.

Verification

  • jest: 19,142 passed, 0 failed (full suite including the new cases)
  • standard: clean

@iyk2h
iyk2h marked this pull request as draft August 25, 2026 01:36
@iyk2h

iyk2h commented Aug 25, 2026

Copy link
Copy Markdown
Author

Converting this to a draft per the feedback in #58 — I've opened a Phase 0 proposal for these operators as a community array extension, following the TC process: https://github.com/orgs/json-logic/discussions/50

Keeping this PR around as the JS reference implementation (the test suite here follows TEST_FORMAT.md). I'll mark it ready or close it depending on how the proposal lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Array containment operators (contains_all / contains_any / contains_none)

1 participant