Skip to content

Add is-subset and is-subset-ci operator modes for list comparison#150

Merged
jeffkala merged 2 commits intonetworktocode:developfrom
michalis1:michalis1-adds-new-operator-check
Mar 11, 2026
Merged

Add is-subset and is-subset-ci operator modes for list comparison#150
jeffkala merged 2 commits intonetworktocode:developfrom
michalis1:michalis1-adds-new-operator-check

Conversation

@michalis1
Copy link
Contributor

Issue #149

This PR introduces two new operator modes to jdiff:

  • is-subset
  • is-subset-ci

These operators allow validation of list-valued fields by checking whether the extracted list is a subset of a reference list. jdiff currently supports scalar comparisons but does not provide a built-in mechanism to validate that an extracted list is contained within an allowed set. This PR adds subset comparison operators to address that use case.

  • is-subset: Validates that the extracted list is a subset of the reference list
  • is-subset-ci: Same as is-subset but case-insensitive

Example:

check_args = {
    "params": {
        "mode": "is-subset",
        "operator_data": allowed_domains
    }
}

Enhancement to associate_key_of_my_value()

A small improvement was required to support extraction paths where a single selected field contains a list value [*].[$id$,include_trusted_domains]. Previously, such cases raised ValueError("Key's value len != from value len") because the function interpreted list elements as separate field values. This required a small enhancement in associate_key_of_my_value() to correctly interpret cases where a single extracted field contains a list value instead of treating the list elements as separate field values.

Example JSON:

[
  {
    "id": "DOMAIN1.COMPANY.COM",
    "include_trusted_domains": [
      "COMPANY.COM",
      "domain1.company.com",
      "domain2.company.COM",
      "domain3.company.com",
      "test.com"
    ]
  }
]

@jeffkala jeffkala merged commit 57b6aa3 into networktocode:develop Mar 11, 2026
12 checks passed
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.

3 participants