#458

feat(core): resolve custom directives on the right-hand side of conditions

Openharold18mwants to merge intofrom

Part 1 of #367.

Comparison operands (eq, neq, gt, gte, lt, lte) only resolved { "$state" }, so a custom directive was compared as a raw object. resolveComparisonValue now looks the operand up in the directive registry, the same way resolvePropValue does for props.

{ "visible": { "$state": "/limit", "lte": { "$count": { "$state": "/cart/items" } } } }
  • Works in element visible (the React renderer already passes a context with directives) and inside $cond in props.
  • Contexts without a registry behave as before.
  • The ComparisonOperators type and both visibility schemas accept a non-empty $-keyed object on gt/gte/lt/lte, so these specs also pass validation (thanks to the Vercel Agent review).

Tests: 5 new cases in directives.test.ts; the two directive cases fail without the change. vitest run packages/core and check-types pass (repeat-schema-parity.test.ts fails locally because it imports a built @json-render/core, unrelated to this change).

The left-hand side ({ "$count": ..., "gt": 0 } as a condition source) touches SingleCondition and its schema, so I'll send it as a separate PR.

Activity

5
copilot-pull-request-reviewer[bot]reviewed5d ago
copilot-pull-request-reviewer[bot]5d ago

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

vercel[bot]5d ago

@harold18m is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot]reviewed5d ago