Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 132 additions & 51 deletions .intent/review-state.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _artifacts/domain_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ skills:
failure_modes:
- mistake: Reuse v1 event-keyed validator configuration
mechanism: The current API uses ordered run objects and separate trigger policies.
correct_pattern: Configure validator arrays with run and triggers.
correct_pattern: Configure validator arrays with run and select interaction events with optional triggers.
source: examples/react/basic/src/index.tsx
priority: HIGH
status: active
version_context: v2.0.0-alpha.3
- mistake: Treat empty triggers as disabling submission
- mistake: Treat omitted or empty triggers as disabling submission
mechanism: Submission validation runs independently of interaction triggers.
correct_pattern: Configure skipOnSubmit explicitly when required.
source: packages/form-core/src/pipeline/validation/formValidators.public.ts
Expand Down
12 changes: 10 additions & 2 deletions _artifacts/skill_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Discovery cases retained for this batch:
| `field-groups` | “Reuse this date-range section when each form stores start and end at different paths.” | “Submit just the current wizard step.” |
| `subscriptions` | “The input changes but its name-length preview stays stale after another edit.” | “Choose when the username availability check should run.” |

Positive combined tasks exercise two skills per consumer. Adjacent negative activation prompts, independent repetitions, and a without-skill comparison remain unmeasured unless explicitly recorded below.
Positive combined tasks loaded two, two, and four skills, respectively, as shown in the observed-load table below. Adjacent negative activation prompts, independent repetitions, and a without-skill comparison remain unmeasured unless explicitly recorded below.

React fresh-consumer evaluation:

Expand All @@ -159,7 +159,7 @@ React fresh-consumer evaluation:
| Reusable range sections in editable rows and another form shape | React `field-groups`, `arrays`, `subscriptions`; core `validation` | Row operations preserve edited values; virtual previews and array meta react; watched validation maps correctly for both shapes. |

- All three consumers' TypeScript checks passed. The separate type grader passed, including seven expected rejection cases for component props, field value types, context paths/providers, and bindings. All 14 browser checks passed in normal and Strict Mode. Inspection found no explicit library-managed call generics or `any` casts in the solutions.
- All evaluated skill hashes match the final working tree, and relative React skill links resolve in the packed layout. No guidance changes were needed after the consumer runs.
- The recorded hashes describe the React evaluation package originally stored under `/tmp/tanstack-react-intent-evaluation/`, before the app-forms example changed from `errorBoundary` to `errorVisibility`. The revised example's type and browser checks are recorded separately below; no fresh-consumer result is recorded for that revision.
- Prompts, starter contracts, protected grading code, reference solutions, negative-control logs, solution diffs, successful-load traces, package archive, skill hashes, and `results.json` are under `/tmp/tanstack-react-intent-evaluation/`. They are disposable evaluation artifacts.
- This verifies one positive combined task per consumer, covering all six React skills. Negative activation cases, repetitions, and a without-skill baseline remain unmeasured; these observations do not establish broader discovery accuracy or improvement over unaided agents.
- Validator compatibility: the generic skill-creator checker rejects Intent's `sources` and `requires` frontmatter extensions. The installed Intent validator is authoritative for this package format and passes all six skills without warnings.
Expand All @@ -185,3 +185,11 @@ React fresh-consumer evaluation:
- The final local package archive contains the new skill. Its relative React links resolve in the installed layout. The domain map records coverage, failure modes, relationships, and the consumer result; the tree records package ownership, sources, purpose, and no prerequisites.
- Task prompts, reference and incorrect solutions, protected checks, consumer implementation, discovery cases, and package archive are under `/tmp/tanstack-form-groups-evaluation/`. This is one positive consumer attempt. Negative discovery cases, repeated attempts, and a without-skill comparison remain unmeasured.
- Validator compatibility remains unchanged: skill-creator's generic checker rejects Intent's `sources` and `requires` extensions. Intent's installed validator supports this format and passes without warnings.

### Source and example review — 2026-11-27

- Evidence: source revision `75a9c6a78631a0841b3ff0c05ac1f6a49cef26e9`, package version `2.0.0-alpha.3`, installed Intent `0.5.6`, and the current skill edits.
- Validation guidance now allows omitted `triggers` for submission-only validators at form, field, and form-group scope, including reusable validator policies. `skipOnSubmit` remains independent. The domain map reflects optional interaction triggers; tree identities, sources, prerequisites, and package placement remain accurate without changes. The optional-property fix in `looseSchema` restores the behavior already described by the form-options skill.
- The async editor keeps loaded data and local edits visible when a background refresh fails. The reusable range example uses time inputs for normalized time values, keeps error messages outside the End label so its accessible name stays stable, and explicitly returns `undefined` on successful validation.
- Verification: both package type checks pass. All 10 examples in the five reviewed skills type-check against the public source entry points. The existing public suites for submission-only validation, group submission, touched defaults, and field groups pass 54 browser checks. Four disposable checks of the published examples pass in normal and Strict Mode, for eight more checks. The range check failed before the label correction and passed afterward.
- The earlier consumer results remain historical evidence. This review corrects the recorded React skill-load counts and distinguishes the evaluated package hashes from later edits. The old disposable evaluation projects are no longer present, and no fresh consumer discovery or task evaluation was run for this revision. The current checks verify the examples directly.
2 changes: 1 addition & 1 deletion packages/form-core/skills/schema-validation/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Pass the options to the adapter's form creation API. Its public package can also

Put the schema directly in `run`. A compatible schema needs no TanStack-specific schema adapter. `strictSchema` and `looseSchema` provide types without registering runtime validation. Read [form options](../form-options/SKILL.md) when choosing between complete and incomplete defaults.

This validator runs on change and on submission. Omitting `triggers` on a form validator leaves submission validation enabled. Read [validation](../validation/SKILL.md) for scheduling and async policies.
This validator runs on change and on submission. Omit `triggers` for submission-only validation at form, field, or form-group scope. Read [validation](../validation/SKILL.md) for scheduling and async policies.

When using Valibot, ArkType, or Effect, read [schema providers](references/schema-providers.md) for the supported integration shape. Check the installed provider version for Standard Schema support.

Expand Down
20 changes: 10 additions & 10 deletions packages/form-core/skills/validation/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ Use an ordered `validators` array of objects with `run`. This is the v2.0.0-alph

## Select events independently from submission

| Configuration | Behavior |
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| Form validator with omitted `triggers`, or any validator with `triggers: []` | Runs on submission by default. |
| `triggers: ['change']` | Also runs on value changes. |
| `triggers: ['blur']` | Also runs on blur. Wire the input's blur handler. |
| `triggers: ['mount']` | Also runs during initialization or mounting for that scope. |
| `skipOnSubmit: true` | Skips client submission validation independently of interaction triggers. |
| `triggerDebounceMs: 300` | Delays change and blur validation. Submission validation is immediate. |
| Configuration | Behavior |
| ------------------------------------ | ------------------------------------------------------------------------- |
| Omitted `triggers` or `triggers: []` | Runs only on submission by default. |
| `triggers: ['change']` | Also runs on value changes. |
| `triggers: ['blur']` | Also runs on blur. Wire the input's blur handler. |
| `triggers: ['mount']` | Also runs during initialization or mounting for that scope. |
| `skipOnSubmit: true` | Skips client submission validation independently of interaction triggers. |
| `triggerDebounceMs: 300` | Delays change and blur validation. Submission validation is immediate. |

Field and group validators require `triggers`. Form validators can omit it. Do not put `'submit'` in `triggers`; submission has its own policy.
`triggers` is optional for form, field, and form-group validators. Do not put `'submit'` in `triggers`; submission has its own policy.

For validation after the first submission attempt, use a trigger condition:

Expand All @@ -82,7 +82,7 @@ export const contactOptions = formOptions.strictSchema(schema, {
})
```

`createValidator` shares one scheduling policy. `createValidators` pairs an ordered tuple of policies with the same number of runners. Keep validator and listener array lengths constant. Use `when` and `skipOnSubmit` for conditions instead of adding or removing entries.
`createValidator` shares one scheduling policy. `createValidators` pairs an ordered tuple of policies with the same number of runners. Both helpers allow policies without `triggers` for submission-only validation. Keep validator and listener array lengths constant. Use `when` and `skipOnSubmit` for conditions instead of adding or removing entries.

Predicates and debounce callbacks must be synchronous and have no side effects. They can inspect values, touched state, or submission attempts. Their call count is unspecified. Validation-state reads in predicates have no ordering guarantee. Use `bailIfInvalid` when a check depends on earlier validation succeeding.

Expand Down
12 changes: 8 additions & 4 deletions packages/form-core/src/pipeline/validation/validation.public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ export interface Validator<
/**
* Mount, change, and blur events that can run this validator, optionally with conditions.
*
* An empty array disables mount, change, and blur validation. Configure
* submission separately with `skipOnSubmit`.
* Omitting this or passing an empty array disables mount, change, and blur
* validation. Configure submission separately with `skipOnSubmit`.
*
* @default []
*/
triggers: Array<
triggers?: Array<
ValidationTriggerOption<TFormData, TContextValue, TTrigger, TScope>
>
}
Expand Down Expand Up @@ -106,7 +108,9 @@ export type ValidatorOptions<
>,
'run' | 'triggers'
> & {
triggers: Array<FormValidationTriggerOption<TFormData, TContextValue, TScope>>
triggers?: Array<
FormValidationTriggerOption<TFormData, TContextValue, TScope>
>
}

type ValidatorRun = StandardSchemaV1<any, any> | ValidatorFn<any, any>
Expand Down
24 changes: 24 additions & 0 deletions packages/form-core/tests/validation.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,30 @@ describe('ValidationTriggerOption', () => {
})

describe('FormErrors', () => {
it('infers schema outputs when reusable validators omit triggers', () => {
const submitOnly = createValidator({})
const validators = createValidators([{}, { skipOnSubmit: true }])(
z.object({ name: z.string() }),
z.object({ name: z.string().transform((value) => value.length) }),
)

expectTypeOf(validators.length).toEqualTypeOf<2>()
expectTypeOf(validators[1].skipOnSubmit).toEqualTypeOf<true>()

formOptions({
defaultValues: { name: '' },
validators: [
submitOnly(z.object({ name: z.string().transform(Number) })),
...validators,
],
onSubmit: ({ validatorOutputs }) => {
expectTypeOf(validatorOutputs).toEqualTypeOf<
[{ name: number }, { name: string }, undefined]
>()
},
})
})

it('exposes failure details and exception suppression in the invalid submit context', () => {
const options = formOptions({
defaultValues: { name: '' },
Expand Down
9 changes: 7 additions & 2 deletions packages/react-form/skills/async-initial-values/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ export function ProfilePage({
error: Error | null
}) {
if (isPending) return <p>Loading…</p>
if (error || !profile) return <p role="alert">Could not load the profile.</p>
return <ProfileEditor key={recordId} profile={profile} />
if (!profile) return <p role="alert">Could not load the profile.</p>
return (
<>
{error && <p role="alert">Could not load the profile.</p>}
<ProfileEditor key={recordId} profile={profile} />
</>
)
}

function ProfileEditor({ profile }: { profile: Profile }) {
Expand Down
24 changes: 15 additions & 9 deletions packages/react-form/skills/field-groups/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function RangeFields({
<label>
Start
<input
type="time"
Comment thread
LeCarbonator marked this conversation as resolved.
Resolved
value={field.value}
onChange={(event) => field.handleChange(event.target.value)}
onBlur={field.handleBlur}
Expand All @@ -64,26 +65,31 @@ function RangeFields({
watchFields: ['start'],
run: ({ value }) => {
const first = fields.getFieldValue('start')
if (first && value && value < first)
if (first && value && value < first) {
return 'End must follow start'
}
return undefined
},
},
]}
>
{(field) => (
<label>
End
<input
value={field.value}
onChange={(event) => field.handleChange(event.target.value)}
onBlur={field.handleBlur}
/>
<>
<label>
End
<input
type="time"
value={field.value}
onChange={(event) => field.handleChange(event.target.value)}
onBlur={field.handleBlur}
/>
</label>
Comment thread
LeCarbonator marked this conversation as resolved.
Resolved
{field.errors.map((error) => (
<span key={error.message} role="alert">
{error.message}
</span>
))}
</label>
</>
)}
</fields.Field>
<output aria-label={`${label} start`}>{start}</output>
Expand Down
3 changes: 1 addition & 2 deletions packages/react-form/skills/form-groups/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function CheckoutWizard() {
},
validators: [
{
triggers: [],
run: z.object({ shipping: addressSchema, billing: addressSchema }),
},
],
Expand Down Expand Up @@ -132,7 +131,7 @@ export function CheckoutWizard() {

The two address steps have the same value shape, so they share one rendered group and schema. Use distinct group components and schemas when steps have different fields. Keep a stable React key per step when switching group names at the same render position.

`group.handleSubmit()` validates the group's fields and group validators. Invalid results prevent its `onSubmit` callback, so navigation belongs in that callback. Group submission leaves unrelated fields and parent validators out of that attempt. `triggers: []` disables interaction validation, but still runs on submission.
`group.handleSubmit()` validates the group's fields and group validators. Invalid results prevent its `onSubmit` callback, so navigation belongs in that callback. Group submission leaves unrelated fields and parent validators out of that attempt. Omit `triggers` or use `triggers: []` for submission-only validation. This applies to form, field, and form-group validators; `skipOnSubmit` controls whether they run on submission.

The last group's callback awaits `form.handleSubmit()`. Only the parent's `onSubmit` saves the complete form. A successful group submission does not prove the complete form is valid. Do not use the group's `isSubmitSuccessful` to declare the wizard complete.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export function GroupValidatorErrors() {
name="details"
validators={[
{
triggers: [],
run: () => ({ message: 'Group error', groupOnly: true as const }),
run: ({ value }) => {
expectTypeOf(value).toEqualTypeOf<{ name: string }>()
return { message: 'Group error', groupOnly: true as const }
},
},
{
triggers: [],
Expand All @@ -36,11 +38,13 @@ export function GroupValidatorErrors() {
name="name"
validators={[
{
triggers: [],
run: () => ({
message: 'Field error',
fromField: true as const,
}),
run: ({ value }) => {
expectTypeOf(value).toEqualTypeOf<string>()
return {
message: 'Field error',
fromField: true as const,
}
},
},
]}
>
Expand Down
Loading
Loading