Skip to content

Add support for Matches Any conditionals - #46

Open
doneill wants to merge 3 commits into
developfrom
task/45-match-any
Open

doneill wants to merge 3 commits into
developfrom
task/45-match-any

Conversation

@doneill

@doneill doneill commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Add support for #45

Proposed Changes

  • In conditions.ts
    • Remove conditionalMatch parameter
    • Group multiple conditions by field
  • Update tests
  • Bump beta version

Implementation Test

In React Native client app, e.g. EarthRanger

- yarn remove @earthranger/react-native-jsonforms-formatter
- yarn add @earthranger/react-native-jsonforms-formatter@2.0.0-beta.35

Unit Tests

jest
 PASS  test/JsonFormatter.test.tsx
 PASS  test/v2.conditions.test.ts
 PASS  test/v2.test.ts
 PASS  test/schemaUtils.test.ts

Test Suites: 4 passed, 4 total
Tests:       174 passed, 174 total
Snapshots:   0 total
Time:        0.672 s, estimated 1 s

Copilot AI lite review requested due to automatic review settings September 15, 2026 20:39
@doneill doneill changed the title Task/45 match any Add support for Matches Any conditionals Sep 15, 2026
@doneill doneill self-assigned this Sep 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Field grouping must safely handle inherited field names.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds V2 support for “matches any” conditionals by grouping conditions by field.

Changes:

  • Groups same-field conditions with anyOf.
  • Combines different fields with allOf.
  • Adds tests and bumps the package to beta.35.
File summaries
File Summary
test/v2.conditions.test.ts Adds tests for same-field and cross-field condition behavior.
src/v2/conditions.ts Implements field grouping. A moderate issue remains for inherited field names such as constructor, toString, and __proto__ (3 votes).
package.json Updates the beta version.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/v2/conditions.ts
Comment on lines +346 to +359
const groupConditionsByField = (conditions: V2Condition[]): V2Condition[][] => {
const order: string[] = [];
const groups: Record<string, V2Condition[]> = {};

conditions.forEach((condition) => {
if (!groups[condition.field]) {
groups[condition.field] = [];
order.push(condition.field);
}
groups[condition.field].push(condition);
});

return order.map((field) => groups[field]);
};
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.

2 participants