Skip to content

[Gap]: add bounded conditional and date-range validation to forms #528

Closed

Description

@jimhoyd

What you were trying to do

In test5/form-lab, an agent built an onboarding form with required fields, email and phone validation, a start date constrained to today through two years ahead, and companyName required only when kind is business.

Where it broke down

The forms extension supports individual field constraints but no bounded cross-field rule or date-range semantics. The agent wrote a custom validate.mjs for both the conditional requirement and relative date comparison, duplicating field extraction and error-map construction.

Code or YAML you had to write by hand

Sanitized hand-written rules: if (kind === "business" && !companyName) errors.companyName = "required"; if (parsedDate < today || parsedDate > twoYearsFromToday) errors.startDate = "out of range". The task also needed a stable field-to-message 422 response.

What you could not verify

This is one benchmark, and its custom implementation passed only 4/9 acceptance checks; the failures are not evidence of a runtime defect. Do not add arbitrary expression evaluation or broad JSON Schema conditionals. Evaluate a portable, declarative subset such as a field-local RFC 3339 date validator with explicit absolute/relative bounds plus a one-level requiredWhen against a declared sibling enum value. Related: #425.

Activity

  1. added
    ai-first
    needs-decision
    on Sep 23, 2026
  2. jimhoyd commented on Sep 24, 2026

    @jimhoyd
    CollaboratorAuthor

    Triage decision: retain as evidence-gathering, not an implementation commitment. Do not add conditional/date validation until repeated independent evidence establishes a bounded, portable subset; preserve the issue guardrails as future acceptance criteria. Removing needs-decision.

  3. added
    enhancement
    extension
    and removed
    needs-decision
    on Sep 24, 2026
  4. jimhoyd commented on Sep 24, 2026

    @jimhoyd
    CollaboratorAuthor

    Decision (owner, 2026-09-24): conditional required fields as requiredWhen: { field, in: [values] } — the referenced field must be a sibling select/enum field and each value one of its declared options (checked at startup); one level only; server-enforced (422). AND/OR chains, not-equal, comparisons, cross-field ordering and show/hide stay in onSubmit. Absolute date bounds are in #697; relative dates remain a follow-up.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-firstenhancementextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions