hashgraph / hashgraph/guardian
Enabling sub schema conditions for elements that are arrays
- Dominant language
- TypeScript
- Stars
- 146
- Forks
- 186
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 126
Description
## **Summary:**
IF conditions currently support `any`/`all` logic only across multiple separate field conditions (e.g., "match if Field A = X OR Field B = Y"). There's a separate, unaddressed gap: when a single field's value is an array (e.g., `field_1: number array`), there's no way to evaluate the condition against the array's individual elements. The system currently only supports `=` for scalar comparisons, so selecting an array-type field breaks the comparison entirely (array vs. scalar mismatch).
**Clarifying the distinction:**
* **Existing (works today):** any/all across _multiple fields_ — e.g., "condition passes if any of \[Field A, Field B, Field C\] equals X"
* **Missing (this ticket):** element-wise logic _within a single array-type field's value_ — e.g., "does this one field's array contain X" or "do all elements in this one field's array equal X"
**Problem:**
Example that currently doesn't work:
* `field_1 (number array, [1,2,3,4,5])` — no operator exists to check `contains 2`
* No way to require every element in `field_1`'s array to equal a value
**Requested behavior:**
Add operators for array-type fields, scoped to a single field's array value:
* `contains` — true if the array includes the specified value
* `each element equals` — true if every element in the array satisfies the condition
* `any element equals` — true if at least one element satisfies the condition
**Acceptance criteria:**
* New operators available when an array-type field is selected in IF condition builder
* Existing scalar `=` and existing any/all (multi-field) behavior remain unchanged
* Validation prevents applying scalar-only operators to array fields without specifying element-wise logic
* Test coverage for each new operator against array field values
* Works in combination with repeatable links
Contributor guide
Assessment
This issue has not been assessed yet.