Skip to content

test: replaceFieldValue should clear onMount errors#2137

Open
Pascalmh wants to merge 1 commit intoTanStack:mainfrom
Pascalmh:fix/replaceFieldValue-onMount
Open

test: replaceFieldValue should clear onMount errors#2137
Pascalmh wants to merge 1 commit intoTanStack:mainfrom
Pascalmh:fix/replaceFieldValue-onMount

Conversation

@Pascalmh
Copy link
Copy Markdown
Contributor

@Pascalmh Pascalmh commented Apr 22, 2026

This is a failing test for now to showcase a bug I think I found.

https://stackblitz.com/edit/github-sn7a9r3i?file=src%2Findex.tsx

Repro:

  • use lines 115-118 instead of lines 120-121
  • Click the "Set Person Names"-Button
  • 👀 Observe: fieldMetaBase["people[0].firstName"].errorMap.onMount is present

🎯 Changes

ToDo

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for form array field replacement operations with schema validation. Tests verify validation errors are properly cleared at both array root and nested field path levels when replacing field values, ensuring consistent and reliable error state tracking.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

Two test suites were extended to verify that form.replaceFieldValue() correctly clears validation errors for both array root fields and nested array element paths when using different schema validators, including Zod and standard validation patterns.

Changes

Cohort / File(s) Summary
Test Additions for Array Field Value Replacement
packages/form-core/tests/standardSchemaValidator.spec.ts, packages/form-core/tests/FormApi.spec.ts
Added comprehensive test cases verifying that replaceFieldValue() clears validation error tracking (errorMap and errorSourceMap) for array fields and nested paths after field value replacement, covering both Zod schema validators and standard validation scenarios.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A hop of joy for tests so true,
Array values swapped anew,
Errors vanish, clean and bright,
Validation guards the code just right!
With each assertion, bugs take flight, 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding tests to verify that replaceFieldValue clears onMount validation errors.
Description check ✅ Passed The PR description provides context about the bug being tested, includes a reproduction case with clear steps, and completes the required checklist sections, though the 'Changes' section is marked as 'ToDo'.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 22, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 5181d57

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ❌ Failed 35s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-22 09:18:06 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 22, 2026

More templates

@tanstack/angular-form

npm i https://pkg.pr.new/@tanstack/angular-form@2137

@tanstack/form-core

npm i https://pkg.pr.new/@tanstack/form-core@2137

@tanstack/form-devtools

npm i https://pkg.pr.new/@tanstack/form-devtools@2137

@tanstack/lit-form

npm i https://pkg.pr.new/@tanstack/lit-form@2137

@tanstack/react-form

npm i https://pkg.pr.new/@tanstack/react-form@2137

@tanstack/react-form-devtools

npm i https://pkg.pr.new/@tanstack/react-form-devtools@2137

@tanstack/react-form-nextjs

npm i https://pkg.pr.new/@tanstack/react-form-nextjs@2137

@tanstack/react-form-remix

npm i https://pkg.pr.new/@tanstack/react-form-remix@2137

@tanstack/react-form-start

npm i https://pkg.pr.new/@tanstack/react-form-start@2137

@tanstack/solid-form

npm i https://pkg.pr.new/@tanstack/solid-form@2137

@tanstack/solid-form-devtools

npm i https://pkg.pr.new/@tanstack/solid-form-devtools@2137

@tanstack/svelte-form

npm i https://pkg.pr.new/@tanstack/svelte-form@2137

@tanstack/vue-form

npm i https://pkg.pr.new/@tanstack/vue-form@2137

commit: 5181d57

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/form-core/tests/standardSchemaValidator.spec.ts`:
- Around line 641-644: Await the asynchronous replaceFieldValue call before
running assertions: change the test to await form.replaceFieldValue('people', 0,
{ firstName: 'Chuck', lastName: 'Norris' }) so validation and meta cleanup
complete before asserting meta state (refer to replaceFieldValue in the test).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f2963067-c53e-4cf6-86a8-ba19a9cb19b5

📥 Commits

Reviewing files that changed from the base of the PR and between 1cdd97a and 0bd9490.

📒 Files selected for processing (1)
  • packages/form-core/tests/standardSchemaValidator.spec.ts

Comment thread packages/form-core/tests/standardSchemaValidator.spec.ts Outdated
@Pascalmh Pascalmh force-pushed the fix/replaceFieldValue-onMount branch from 0bd9490 to 5211f19 Compare April 22, 2026 08:52
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/framework/react/reference/interfaces/UseFieldOptionsBound.md`:
- Line 8: The "Defined in" links in
docs/framework/react/reference/interfaces/UseFieldOptionsBound.md currently
point to a personal fork; update those URLs (at the occurrences on line 8 and
line 72) to reference the upstream main repository instead (replace the forked
repo path with the canonical tanstack-form repo path), ensuring the links still
target the same file and line (packages/react-form/src/types.ts:81) so the
UseFieldOptionsBound "Defined in" references are correct and not stale.

In `@docs/framework/solid/reference/interfaces/CreateFieldOptionsBound.md`:
- Line 8: The "Defined in" links in CreateFieldOptionsBound.md currently point
to a personal fork (Pascalmh/tanstack-form); update those markdown links (the
"Defined in: [packages/solid-form/src/types.ts:77]" references) to use the
canonical upstream repository URL instead of the fork (replace
Pascalmh/tanstack-form with the official upstream repo host/path used by this
project), and apply the same replacement for the duplicate link referenced later
in the file so both source links resolve to the canonical repo.

In `@docs/framework/vue/reference/interfaces/VueFieldApi.md`:
- Line 8: The docs contain "Defined in" source links pointing to the fork
(github.com/Pascalmh/tanstack-form); update them to the canonical repository
(github.com/TanStack/form). Search files like VueFieldApi.md (the "Defined in"
link that references packages/vue-form/src/useField.tsx:158) and replace the
Pascalmh URL with the TanStack/form URL, ensuring the path and line anchor
(e.g., packages/vue-form/src/useField.tsx:158) are preserved exactly; apply the
same replacement across all other generated docs that reference the forked repo.

In `@docs/framework/vue/reference/interfaces/VueFormApi.md`:
- Line 8: Replace fork-owned GitHub URLs in
docs/framework/vue/reference/interfaces/VueFormApi.md that point to
packages/vue-form/src/useForm.tsx (they currently reference the Pascalmh fork)
with the canonical repository URLs (the main tanstack/form repo) so all "Defined
in" links point to the upstream source; update each occurrence that targets
packages/vue-form/src/useForm.tsx (the five links in this file) to the canonical
repo path.

In `@packages/form-core/tests/FormApi.spec.ts`:
- Line 381: The test declares the validator error maps with "let fieldErrors"
but they are only mutated (properties updated) and never reassigned; change the
declaration of fieldErrors to "const fieldErrors" in the test(s) (references to
fieldErrors around the assertions at the locations shown) so ESLint no longer
flags reassignment, and ensure any code that currently reassigns the variable is
updated to mutate its properties instead of reassigning the identifier (apply
the same change for the other occurrence noted near line 404).
- Around line 428-452: The failing test shows stale onMount metadata and error
entries remain after calling FormApi.replaceFieldValue; update the production
implementation of replaceFieldValue (the method named replaceFieldValue on the
FormApi class) to purge/refresh any onMount-related metadata and error maps for
the replaced array field and all nested child keys (e.g., clear entries in
form.state.fieldMetaBase for keys like 'people[0].*' and remove related
errorMap/errorSourceMap/onMount flags) whenever elements are replaced or
shifted; after that, tighten the test by first asserting the initial onMount
errors exist for both firstName and lastName before calling replaceFieldValue
and then assert both firstName and lastName errorMap/errorSourceMap are cleared
afterwards (the test touches form.mount, new FieldApi({ form, name: 'people'
}).mount(), replaceFieldValue, and checks
fieldMetaBase/errorMap/errorSourceMap).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2707d07-e536-4350-a306-3eaebe38c375

📥 Commits

Reviewing files that changed from the base of the PR and between 0bd9490 and 4ada3d6.

📒 Files selected for processing (142)
  • docs/framework/angular/reference/classes/TanStackAppField.md
  • docs/framework/angular/reference/classes/TanStackField.md
  • docs/framework/angular/reference/classes/TanStackFieldInjectable.md
  • docs/framework/angular/reference/functions/injectField.md
  • docs/framework/angular/reference/functions/injectForm.md
  • docs/framework/angular/reference/functions/injectStore.md
  • docs/framework/lit/reference/classes/TanStackFormController.md
  • docs/framework/react/reference/functions/createFormHook.md
  • docs/framework/react/reference/functions/createFormHookContexts.md
  • docs/framework/react/reference/functions/useField.md
  • docs/framework/react/reference/functions/useFieldGroup.md
  • docs/framework/react/reference/functions/useForm.md
  • docs/framework/react/reference/interfaces/ReactFormApi.md
  • docs/framework/react/reference/interfaces/UseFieldOptions.md
  • docs/framework/react/reference/interfaces/UseFieldOptionsBound.md
  • docs/framework/react/reference/interfaces/WithFieldGroupProps.md
  • docs/framework/react/reference/interfaces/WithFormProps.md
  • docs/framework/react/reference/type-aliases/FieldComponent.md
  • docs/framework/react/reference/type-aliases/LensFieldComponent.md
  • docs/framework/react/reference/type-aliases/ReactFormExtendedApi.md
  • docs/framework/react/reference/type-aliases/ServerFormState.md
  • docs/framework/react/reference/type-aliases/UseField.md
  • docs/framework/react/reference/variables/Field.md
  • docs/framework/react/reference/variables/useIsomorphicLayoutEffect.md
  • docs/framework/solid/reference/functions/Field.md
  • docs/framework/solid/reference/functions/createField.md
  • docs/framework/solid/reference/functions/createFieldGroup.md
  • docs/framework/solid/reference/functions/createForm.md
  • docs/framework/solid/reference/functions/createFormHook.md
  • docs/framework/solid/reference/functions/createFormHookContexts.md
  • docs/framework/solid/reference/interfaces/CreateFieldOptions.md
  • docs/framework/solid/reference/interfaces/CreateFieldOptionsBound.md
  • docs/framework/solid/reference/interfaces/SolidFormApi.md
  • docs/framework/solid/reference/interfaces/WithFieldGroupProps.md
  • docs/framework/solid/reference/interfaces/WithFormProps.md
  • docs/framework/solid/reference/type-aliases/CreateField.md
  • docs/framework/solid/reference/type-aliases/FieldComponent.md
  • docs/framework/solid/reference/type-aliases/LensFieldComponent.md
  • docs/framework/solid/reference/type-aliases/SolidFormExtendedApi.md
  • docs/framework/vue/reference/functions/useField.md
  • docs/framework/vue/reference/functions/useForm.md
  • docs/framework/vue/reference/interfaces/VueFieldApi.md
  • docs/framework/vue/reference/interfaces/VueFormApi.md
  • docs/framework/vue/reference/type-aliases/FieldComponent.md
  • docs/framework/vue/reference/type-aliases/FieldComponentBoundProps.md
  • docs/framework/vue/reference/type-aliases/FieldComponentProps.md
  • docs/framework/vue/reference/type-aliases/UseField.md
  • docs/framework/vue/reference/variables/Field.md
  • docs/reference/classes/FieldApi.md
  • docs/reference/classes/FieldGroupApi.md
  • docs/reference/classes/FormApi.md
  • docs/reference/functions/createFieldMap.md
  • docs/reference/functions/deepCopy.md
  • docs/reference/functions/evaluate.md
  • docs/reference/functions/formOptions.md
  • docs/reference/functions/isGlobalFormValidationError.md
  • docs/reference/functions/isStandardSchemaValidator.md
  • docs/reference/functions/mergeForm.md
  • docs/reference/functions/revalidateLogic.md
  • docs/reference/functions/uuid.md
  • docs/reference/interfaces/AnyDeepKeyAndValue.md
  • docs/reference/interfaces/ArrayDeepKeyAndValue.md
  • docs/reference/interfaces/BaseFormOptions.md
  • docs/reference/interfaces/FieldApiOptions.md
  • docs/reference/interfaces/FieldGroupOptions.md
  • docs/reference/interfaces/FieldGroupState.md
  • docs/reference/interfaces/FieldListeners.md
  • docs/reference/interfaces/FieldOptions.md
  • docs/reference/interfaces/FieldValidators.md
  • docs/reference/interfaces/FormListeners.md
  • docs/reference/interfaces/FormOptions.md
  • docs/reference/interfaces/FormState.md
  • docs/reference/interfaces/FormValidators.md
  • docs/reference/interfaces/ObjectDeepKeyAndValue.md
  • docs/reference/interfaces/StandardSchemaV1Issue.md
  • docs/reference/interfaces/TupleDeepKeyAndValue.md
  • docs/reference/interfaces/UnknownDeepKeyAndValue.md
  • docs/reference/interfaces/ValidationLogicProps.md
  • docs/reference/interfaces/ValidationLogicValidatorsFn.md
  • docs/reference/type-aliases/AllObjectKeys.md
  • docs/reference/type-aliases/AllTupleKeys.md
  • docs/reference/type-aliases/AnyBaseFormState.md
  • docs/reference/type-aliases/AnyFieldApi.md
  • docs/reference/type-aliases/AnyFieldGroupApi.md
  • docs/reference/type-aliases/AnyFieldMeta.md
  • docs/reference/type-aliases/AnyFieldMetaBase.md
  • docs/reference/type-aliases/AnyFieldMetaDerived.md
  • docs/reference/type-aliases/AnyFormApi.md
  • docs/reference/type-aliases/AnyFormOptions.md
  • docs/reference/type-aliases/AnyFormState.md
  • docs/reference/type-aliases/ArrayAccessor.md
  • docs/reference/type-aliases/BaseFormState.md
  • docs/reference/type-aliases/BroadcastFormApi.md
  • docs/reference/type-aliases/BroadcastFormId.md
  • docs/reference/type-aliases/BroadcastFormState.md
  • docs/reference/type-aliases/BroadcastFormSubmissionState.md
  • docs/reference/type-aliases/DeepKeyAndValueArray.md
  • docs/reference/type-aliases/DeepKeyAndValueObject.md
  • docs/reference/type-aliases/DeepKeyAndValueTuple.md
  • docs/reference/type-aliases/DeepKeys.md
  • docs/reference/type-aliases/DeepKeysAndValues.md
  • docs/reference/type-aliases/DeepKeysAndValuesImpl.md
  • docs/reference/type-aliases/DeepKeysOfType.md
  • docs/reference/type-aliases/DeepRecord.md
  • docs/reference/type-aliases/DeepValue.md
  • docs/reference/type-aliases/DerivedFormState.md
  • docs/reference/type-aliases/EventClientEventMap.md
  • docs/reference/type-aliases/EventClientEventNames.md
  • docs/reference/type-aliases/ExtractGlobalFormError.md
  • docs/reference/type-aliases/FieldInfo.md
  • docs/reference/type-aliases/FieldMeta.md
  • docs/reference/type-aliases/FieldMetaBase.md
  • docs/reference/type-aliases/FieldMetaDerived.md
  • docs/reference/type-aliases/FieldState.md
  • docs/reference/type-aliases/FieldsMap.md
  • docs/reference/type-aliases/FormValidateFn.md
  • docs/reference/type-aliases/FormValidationError.md
  • docs/reference/type-aliases/FormValidator.md
  • docs/reference/type-aliases/Nullable.md
  • docs/reference/type-aliases/ObjectAccessor.md
  • docs/reference/type-aliases/ObjectValue.md
  • docs/reference/type-aliases/StandardSchemaV1.md
  • docs/reference/type-aliases/TStandardSchemaValidatorIssue.md
  • docs/reference/type-aliases/TStandardSchemaValidatorValue.md
  • docs/reference/type-aliases/TupleAccessor.md
  • docs/reference/type-aliases/UnknownAccessor.md
  • docs/reference/type-aliases/UnwrapFieldAsyncValidateOrFn.md
  • docs/reference/type-aliases/UnwrapFieldValidateOrFn.md
  • docs/reference/type-aliases/UnwrapFormAsyncValidateOrFn.md
  • docs/reference/type-aliases/UnwrapFormValidateOrFn.md
  • docs/reference/type-aliases/Updater.md
  • docs/reference/type-aliases/UpdaterFn.md
  • docs/reference/type-aliases/ValidationError.md
  • docs/reference/type-aliases/ValidationLogicFn.md
  • docs/reference/type-aliases/ValidationMeta.md
  • docs/reference/type-aliases/ValidationSource.md
  • docs/reference/variables/defaultValidationLogic.md
  • docs/reference/variables/formEventClient.md
  • docs/reference/variables/standardSchemaValidators.md
  • docs/reference/variables/throttleFormState.md
  • packages/form-core/tests/FormApi.spec.ts
  • packages/form-core/tests/standardSchemaValidator.spec.ts
✅ Files skipped from review due to trivial changes (130)
  • docs/reference/type-aliases/ObjectValue.md
  • docs/framework/react/reference/type-aliases/ReactFormExtendedApi.md
  • docs/framework/angular/reference/functions/injectForm.md
  • docs/framework/react/reference/type-aliases/UseField.md
  • docs/reference/interfaces/ObjectDeepKeyAndValue.md
  • docs/reference/type-aliases/AnyFormOptions.md
  • docs/reference/functions/deepCopy.md
  • docs/framework/solid/reference/functions/createField.md
  • docs/reference/functions/isStandardSchemaValidator.md
  • docs/reference/type-aliases/AnyBaseFormState.md
  • docs/reference/type-aliases/AnyFieldGroupApi.md
  • docs/framework/react/reference/variables/useIsomorphicLayoutEffect.md
  • docs/framework/angular/reference/functions/injectStore.md
  • docs/reference/type-aliases/TStandardSchemaValidatorIssue.md
  • docs/reference/variables/throttleFormState.md
  • docs/reference/functions/revalidateLogic.md
  • docs/framework/vue/reference/type-aliases/FieldComponent.md
  • docs/reference/functions/isGlobalFormValidationError.md
  • docs/framework/vue/reference/type-aliases/UseField.md
  • docs/reference/type-aliases/FieldMeta.md
  • docs/framework/react/reference/interfaces/WithFieldGroupProps.md
  • docs/reference/type-aliases/UnknownAccessor.md
  • docs/reference/variables/formEventClient.md
  • docs/framework/react/reference/functions/useForm.md
  • docs/framework/vue/reference/variables/Field.md
  • docs/reference/type-aliases/FormValidateFn.md
  • docs/reference/type-aliases/DeepKeyAndValueArray.md
  • docs/reference/type-aliases/ValidationLogicFn.md
  • docs/reference/variables/defaultValidationLogic.md
  • docs/framework/react/reference/type-aliases/ServerFormState.md
  • docs/reference/type-aliases/BroadcastFormSubmissionState.md
  • docs/reference/type-aliases/AnyFieldMeta.md
  • docs/reference/type-aliases/AnyFormState.md
  • docs/reference/interfaces/BaseFormOptions.md
  • docs/reference/functions/formOptions.md
  • docs/reference/type-aliases/DeepKeysAndValues.md
  • docs/reference/functions/createFieldMap.md
  • docs/reference/type-aliases/AnyFieldApi.md
  • docs/reference/interfaces/FieldOptions.md
  • docs/framework/solid/reference/type-aliases/FieldComponent.md
  • docs/framework/solid/reference/functions/Field.md
  • docs/framework/solid/reference/type-aliases/SolidFormExtendedApi.md
  • docs/reference/type-aliases/UnwrapFormAsyncValidateOrFn.md
  • docs/reference/type-aliases/DeepKeys.md
  • docs/reference/functions/evaluate.md
  • docs/framework/react/reference/variables/Field.md
  • docs/reference/type-aliases/ExtractGlobalFormError.md
  • docs/reference/type-aliases/AllObjectKeys.md
  • docs/framework/vue/reference/functions/useField.md
  • docs/framework/solid/reference/interfaces/WithFieldGroupProps.md
  • docs/framework/react/reference/functions/useFieldGroup.md
  • docs/framework/solid/reference/functions/createForm.md
  • docs/reference/type-aliases/UpdaterFn.md
  • docs/reference/interfaces/UnknownDeepKeyAndValue.md
  • docs/framework/angular/reference/functions/injectField.md
  • docs/framework/vue/reference/type-aliases/FieldComponentProps.md
  • docs/reference/type-aliases/AnyFieldMetaBase.md
  • docs/reference/type-aliases/ValidationError.md
  • docs/framework/solid/reference/functions/createFormHookContexts.md
  • docs/reference/type-aliases/ValidationSource.md
  • docs/reference/type-aliases/StandardSchemaV1.md
  • docs/reference/type-aliases/FormValidator.md
  • docs/reference/type-aliases/ArrayAccessor.md
  • docs/reference/type-aliases/AnyFieldMetaDerived.md
  • docs/framework/react/reference/interfaces/ReactFormApi.md
  • docs/reference/functions/uuid.md
  • docs/framework/react/reference/interfaces/UseFieldOptions.md
  • docs/reference/classes/FieldApi.md
  • docs/framework/react/reference/type-aliases/FieldComponent.md
  • docs/framework/solid/reference/functions/createFormHook.md
  • docs/reference/type-aliases/Updater.md
  • docs/reference/type-aliases/EventClientEventNames.md
  • docs/reference/type-aliases/EventClientEventMap.md
  • docs/reference/type-aliases/UnwrapFieldAsyncValidateOrFn.md
  • docs/reference/type-aliases/FieldsMap.md
  • docs/reference/type-aliases/DeepKeysOfType.md
  • docs/reference/type-aliases/AllTupleKeys.md
  • docs/reference/type-aliases/FormValidationError.md
  • docs/framework/solid/reference/functions/createFieldGroup.md
  • docs/reference/type-aliases/ValidationMeta.md
  • docs/reference/functions/mergeForm.md
  • docs/reference/interfaces/FieldGroupOptions.md
  • docs/reference/type-aliases/DeepKeysAndValuesImpl.md
  • docs/framework/react/reference/type-aliases/LensFieldComponent.md
  • docs/reference/interfaces/ValidationLogicProps.md
  • docs/reference/interfaces/ArrayDeepKeyAndValue.md
  • docs/reference/type-aliases/ObjectAccessor.md
  • docs/reference/interfaces/ValidationLogicValidatorsFn.md
  • docs/framework/vue/reference/type-aliases/FieldComponentBoundProps.md
  • docs/reference/type-aliases/FieldState.md
  • docs/framework/react/reference/functions/createFormHookContexts.md
  • docs/reference/type-aliases/BroadcastFormId.md
  • docs/reference/type-aliases/DeepKeyAndValueObject.md
  • docs/framework/solid/reference/type-aliases/CreateField.md
  • docs/reference/type-aliases/UnwrapFormValidateOrFn.md
  • docs/reference/type-aliases/UnwrapFieldValidateOrFn.md
  • docs/framework/vue/reference/functions/useForm.md
  • docs/framework/angular/reference/classes/TanStackAppField.md
  • docs/reference/interfaces/FormValidators.md
  • docs/reference/interfaces/AnyDeepKeyAndValue.md
  • docs/reference/type-aliases/BaseFormState.md
  • docs/reference/type-aliases/DeepValue.md
  • docs/framework/angular/reference/classes/TanStackField.md
  • docs/reference/type-aliases/Nullable.md
  • docs/reference/type-aliases/FieldMetaDerived.md
  • docs/reference/type-aliases/AnyFormApi.md
  • docs/reference/type-aliases/BroadcastFormState.md
  • docs/reference/classes/FieldGroupApi.md
  • docs/reference/type-aliases/DerivedFormState.md
  • docs/reference/type-aliases/FieldInfo.md
  • docs/reference/classes/FormApi.md
  • docs/reference/interfaces/FieldListeners.md
  • docs/reference/type-aliases/DeepKeyAndValueTuple.md
  • docs/reference/interfaces/StandardSchemaV1Issue.md
  • docs/reference/interfaces/FormOptions.md
  • docs/framework/react/reference/functions/createFormHook.md
  • docs/reference/interfaces/FieldApiOptions.md
  • docs/reference/type-aliases/FieldMetaBase.md
  • docs/reference/interfaces/FormState.md
  • docs/framework/lit/reference/classes/TanStackFormController.md
  • docs/reference/type-aliases/TStandardSchemaValidatorValue.md
  • docs/reference/interfaces/FieldGroupState.md
  • packages/form-core/tests/standardSchemaValidator.spec.ts
  • docs/reference/type-aliases/TupleAccessor.md
  • docs/framework/react/reference/functions/useField.md
  • docs/reference/type-aliases/BroadcastFormApi.md
  • docs/framework/angular/reference/classes/TanStackFieldInjectable.md
  • docs/framework/solid/reference/type-aliases/LensFieldComponent.md
  • docs/reference/type-aliases/DeepRecord.md
  • docs/reference/interfaces/TupleDeepKeyAndValue.md

# Interface: UseFieldOptionsBound\<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync\>

Defined in: [packages/react-form/src/types.ts:81](https://github.com/TanStack/form/blob/main/packages/react-form/src/types.ts#L81)
Defined in: [packages/react-form/src/types.ts:81](https://github.com/Pascalmh/tanstack-form/blob/main/packages/react-form/src/types.ts#L81)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Revert “Defined in” URLs to upstream repo.

Line 8 and Line 72 should not point to a personal fork. Keeping these links on the main repository avoids stale references in user-facing documentation.

Also applies to: 72-72

🧰 Tools
🪛 LanguageTool

[typographical] ~8-~8: Niet-gecombineerd symbool: “]” lijkt te ontbreken
Context: ...Dynamic, TOnDynamicAsync> Defined in: [packages/react-form/src/types.ts:81](htt...

(UNPAIRED_BRACKETS)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/framework/react/reference/interfaces/UseFieldOptionsBound.md` at line 8,
The "Defined in" links in
docs/framework/react/reference/interfaces/UseFieldOptionsBound.md currently
point to a personal fork; update those URLs (at the occurrences on line 8 and
line 72) to reference the upstream main repository instead (replace the forked
repo path with the canonical tanstack-form repo path), ensuring the links still
target the same file and line (packages/react-form/src/types.ts:81) so the
UseFieldOptionsBound "Defined in" references are correct and not stale.

# Interface: CreateFieldOptionsBound\<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync\>

Defined in: [packages/solid-form/src/types.ts:77](https://github.com/TanStack/form/blob/main/packages/solid-form/src/types.ts#L77)
Defined in: [packages/solid-form/src/types.ts:77](https://github.com/Pascalmh/tanstack-form/blob/main/packages/solid-form/src/types.ts#L77)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use canonical repository links for “Defined in” URLs.

Line 8 and Line 72 now point to a personal fork (Pascalmh/tanstack-form). In published project docs, these should point to the canonical upstream repo to avoid stale/broken source links over time.

Also applies to: 72-72

🧰 Tools
🪛 LanguageTool

[typographical] ~8-~8: Niet-gecombineerd symbool: “]” lijkt te ontbreken
Context: ...Dynamic, TOnDynamicAsync> Defined in: [packages/solid-form/src/types.ts:77](htt...

(UNPAIRED_BRACKETS)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/framework/solid/reference/interfaces/CreateFieldOptionsBound.md` at line
8, The "Defined in" links in CreateFieldOptionsBound.md currently point to a
personal fork (Pascalmh/tanstack-form); update those markdown links (the
"Defined in: [packages/solid-form/src/types.ts:77]" references) to use the
canonical upstream repository URL instead of the fork (replace
Pascalmh/tanstack-form with the official upstream repo host/path used by this
project), and apply the same replacement for the duplicate link referenced later
in the file so both source links resolve to the canonical repo.

# Interface: VueFieldApi\<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta\>

Defined in: [packages/vue-form/src/useField.tsx:158](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useField.tsx#L158)
Defined in: [packages/vue-form/src/useField.tsx:158](https://github.com/Pascalmh/tanstack-form/blob/main/packages/vue-form/src/useField.tsx#L158)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find all documentation files with Pascalmh repository references

rg -n "github\.com/Pascalmh/tanstack-form" --glob "docs/**/*.md"

Repository: TanStack/form

Length of output: 50369


Revert all documentation URLs to the canonical TanStack repository.

Documentation "Defined in" source links across multiple files reference github.com/Pascalmh/tanstack-form instead of the canonical github.com/TanStack/form. These URLs must be reverted before merging to ensure:

  • Links remain stable and don't break if the fork is deleted or made private
  • Documentation follows standard open source practices
  • Users access the official source code repository

This likely occurred because the automated documentation generation ran from the fork's context. All affected documentation files need correction.

🧰 Tools
🪛 LanguageTool

[typographical] ~8-~8: Niet-gecombineerd symbool: “]” lijkt te ontbreken
Context: ...erver, TParentSubmitMeta> Defined in: [packages/vue-form/src/useField.tsx:158](...

(UNPAIRED_BRACKETS)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/framework/vue/reference/interfaces/VueFieldApi.md` at line 8, The docs
contain "Defined in" source links pointing to the fork
(github.com/Pascalmh/tanstack-form); update them to the canonical repository
(github.com/TanStack/form). Search files like VueFieldApi.md (the "Defined in"
link that references packages/vue-form/src/useField.tsx:158) and replace the
Pascalmh URL with the TanStack/form URL, ensuring the path and line anchor
(e.g., packages/vue-form/src/useField.tsx:158) are preserved exactly; apply the
same replacement across all other generated docs that reference the forked repo.

# Interface: VueFormApi\<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TSubmitMeta\>

Defined in: [packages/vue-form/src/useForm.tsx:124](https://github.com/TanStack/form/blob/main/packages/vue-form/src/useForm.tsx#L124)
Defined in: [packages/vue-form/src/useForm.tsx:124](https://github.com/Pascalmh/tanstack-form/blob/main/packages/vue-form/src/useForm.tsx#L124)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Avoid fork-owned links in framework docs.

Line 8, Line 68, Line 78, Line 88, and Line 98 should reference the canonical repository, not a contributor fork. This prevents future link rot and keeps API docs aligned with the main codebase.

Also applies to: 68-68, 78-78, 88-88, 98-98

🧰 Tools
🪛 LanguageTool

[typographical] ~8-~8: Niet-gecombineerd symbool: “]” lijkt te ontbreken
Context: ...ormOnServer, TSubmitMeta> Defined in: [packages/vue-form/src/useForm.tsx:124](h...

(UNPAIRED_BRACKETS)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/framework/vue/reference/interfaces/VueFormApi.md` at line 8, Replace
fork-owned GitHub URLs in docs/framework/vue/reference/interfaces/VueFormApi.md
that point to packages/vue-form/src/useForm.tsx (they currently reference the
Pascalmh fork) with the canonical repository URLs (the main tanstack/form repo)
so all "Defined in" links point to the upstream source; update each occurrence
that targets packages/vue-form/src/useForm.tsx (the five links in this file) to
the canonical repo path.

},
validators: {
onMount: ({ value }) => {
let fieldErrors: Record<string, string> = {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use const for the validator error maps.

fieldErrors is mutated but never reassigned, and ESLint is failing on Lines 381 and 404.

Proposed fix
-          let fieldErrors: Record<string, string> = {}
+          const fieldErrors: Record<string, string> = {}

-          let fieldErrors: Record<string, string> = {}
+          const fieldErrors: Record<string, string> = {}

Also applies to: 404-404

🧰 Tools
🪛 ESLint

[error] 381-381: 'fieldErrors' is never reassigned. Use 'const' instead.

(prefer-const)

🪛 GitHub Actions: PR

[error] 381-381: ESLint (prefer-const): 'fieldErrors' is never reassigned. Use 'const' instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/form-core/tests/FormApi.spec.ts` at line 381, The test declares the
validator error maps with "let fieldErrors" but they are only mutated
(properties updated) and never reassigned; change the declaration of fieldErrors
to "const fieldErrors" in the test(s) (references to fieldErrors around the
assertions at the locations shown) so ESLint no longer flags reassignment, and
ensure any code that currently reassigns the variable is updated to mutate its
properties instead of reassigning the identifier (apply the same change for the
other occurrence noted near line 404).

Comment on lines +428 to +452
form.mount()

// Since validation runs through the field, a field must be mounted for that array
new FieldApi({ form, name: 'people' }).mount()

await form.replaceFieldValue('people', 0, {
firstName: 'Chuck',
lastName: 'Norris',
})

expect(form.state.values).toStrictEqual({
people: [
{
firstName: 'Chuck',
lastName: 'Norris',
},
],
})
expect.soft(form.state.fieldMetaBase['people']!.errorMap).toStrictEqual({})
expect
.soft(form.state.fieldMetaBase['people[0].firstName']!.errorMap)
.toStrictEqual({})
expect
.soft(form.state.fieldMetaBase['people[0].firstName']!.errorSourceMap)
.toStrictEqual({})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add the implementation fix and tighten the regression assertions before merge.

CI is currently red on Lines 446, 449, and 452 because the stale onMount metadata remains after replaceFieldValue. If this PR is intended to merge, please include the production fix; if it is only a repro, keep it non-mergeable/draft.

Also, the test creates lastName errors but only checks firstName, and it does not assert the initial onMount errors exist before replacement.

Optional test tightening after the production fix
     // Since validation runs through the field, a field must be mounted for that array
     new FieldApi({ form, name: 'people' }).mount()
 
+    expect
+      .soft(form.state.fieldMetaBase['people[0].firstName']!.errorMap)
+      .toMatchObject({ onMount: 'First name is too short' })
+    expect
+      .soft(form.state.fieldMetaBase['people[0].lastName']!.errorMap)
+      .toMatchObject({ onMount: 'Last name is too short' })
+
     await form.replaceFieldValue('people', 0, {
       firstName: 'Chuck',
       lastName: 'Norris',
     })
@@
     expect
       .soft(form.state.fieldMetaBase['people[0].firstName']!.errorSourceMap)
       .toStrictEqual({})
+    expect
+      .soft(form.state.fieldMetaBase['people[0].lastName']!.errorMap)
+      .toStrictEqual({})
+    expect
+      .soft(form.state.fieldMetaBase['people[0].lastName']!.errorSourceMap)
+      .toStrictEqual({})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
form.mount()
// Since validation runs through the field, a field must be mounted for that array
new FieldApi({ form, name: 'people' }).mount()
await form.replaceFieldValue('people', 0, {
firstName: 'Chuck',
lastName: 'Norris',
})
expect(form.state.values).toStrictEqual({
people: [
{
firstName: 'Chuck',
lastName: 'Norris',
},
],
})
expect.soft(form.state.fieldMetaBase['people']!.errorMap).toStrictEqual({})
expect
.soft(form.state.fieldMetaBase['people[0].firstName']!.errorMap)
.toStrictEqual({})
expect
.soft(form.state.fieldMetaBase['people[0].firstName']!.errorSourceMap)
.toStrictEqual({})
form.mount()
// Since validation runs through the field, a field must be mounted for that array
new FieldApi({ form, name: 'people' }).mount()
expect
.soft(form.state.fieldMetaBase['people[0].firstName']!.errorMap)
.toMatchObject({ onMount: 'First name is too short' })
expect
.soft(form.state.fieldMetaBase['people[0].lastName']!.errorMap)
.toMatchObject({ onMount: 'Last name is too short' })
await form.replaceFieldValue('people', 0, {
firstName: 'Chuck',
lastName: 'Norris',
})
expect(form.state.values).toStrictEqual({
people: [
{
firstName: 'Chuck',
lastName: 'Norris',
},
],
})
expect.soft(form.state.fieldMetaBase['people']!.errorMap).toStrictEqual({})
expect
.soft(form.state.fieldMetaBase['people[0].firstName']!.errorMap)
.toStrictEqual({})
expect
.soft(form.state.fieldMetaBase['people[0].firstName']!.errorSourceMap)
.toStrictEqual({})
expect
.soft(form.state.fieldMetaBase['people[0].lastName']!.errorMap)
.toStrictEqual({})
expect
.soft(form.state.fieldMetaBase['people[0].lastName']!.errorSourceMap)
.toStrictEqual({})
🧰 Tools
🪛 GitHub Actions: PR

[error] 446-446: Vitest failed: expected { onMount: undefined } to strictly equal {}.


[error] 449-449: Vitest failed: expected { onMount: 'First name is too short' } to strictly equal {}.


[error] 452-452: Vitest failed: expected { onMount: 'form' } to strictly equal {}.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/form-core/tests/FormApi.spec.ts` around lines 428 - 452, The failing
test shows stale onMount metadata and error entries remain after calling
FormApi.replaceFieldValue; update the production implementation of
replaceFieldValue (the method named replaceFieldValue on the FormApi class) to
purge/refresh any onMount-related metadata and error maps for the replaced array
field and all nested child keys (e.g., clear entries in form.state.fieldMetaBase
for keys like 'people[0].*' and remove related errorMap/errorSourceMap/onMount
flags) whenever elements are replaced or shifted; after that, tighten the test
by first asserting the initial onMount errors exist for both firstName and
lastName before calling replaceFieldValue and then assert both firstName and
lastName errorMap/errorSourceMap are cleared afterwards (the test touches
form.mount, new FieldApi({ form, name: 'people' }).mount(), replaceFieldValue,
and checks fieldMetaBase/errorMap/errorSourceMap).

@Pascalmh Pascalmh force-pushed the fix/replaceFieldValue-onMount branch from 4ada3d6 to 5181d57 Compare April 22, 2026 09:16
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
packages/form-core/tests/FormApi.spec.ts (2)

381-381: ⚠️ Potential issue | 🟡 Minor

Use const for fieldErrors declarations.

At Line 381 and Line 404, fieldErrors is mutated but never reassigned, so let should be const to satisfy prefer-const.

Suggested fix
-          let fieldErrors: Record<string, string> = {}
+          const fieldErrors: Record<string, string> = {}
...
-          let fieldErrors: Record<string, string> = {}
+          const fieldErrors: Record<string, string> = {}

Also applies to: 404-404

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/form-core/tests/FormApi.spec.ts` at line 381, Change the `let
fieldErrors: Record<string, string> = {}` declarations to `const fieldErrors:
Record<string, string> = {}` in the test file where `fieldErrors` is defined
(the variable named `fieldErrors` in the FormApi.spec.ts test cases), since the
object is mutated but never reassigned; update both occurrences so ESLint's
prefer-const is satisfied and tests still mutate properties on the same object
instance.

433-452: ⚠️ Potential issue | 🟠 Major

Tighten the regression assertions to cover both nested fields and preconditions.

The test currently validates cleanup only for people[0].firstName after replace, but the validator creates onMount errors for both firstName and lastName. Also, it doesn’t assert the initial onMount state before replacement, so the regression signal is weaker.

Suggested test tightening
     // Since validation runs through the field, a field must be mounted for that array
     new FieldApi({ form, name: 'people' }).mount()

+    expect
+      .soft(form.state.fieldMetaBase['people[0].firstName']!.errorMap)
+      .toMatchObject({ onMount: 'First name is too short' })
+    expect
+      .soft(form.state.fieldMetaBase['people[0].lastName']!.errorMap)
+      .toMatchObject({ onMount: 'Last name is too short' })
+
     await form.replaceFieldValue('people', 0, {
       firstName: 'Chuck',
       lastName: 'Norris',
     })
@@
     expect
       .soft(form.state.fieldMetaBase['people[0].firstName']!.errorSourceMap)
       .toStrictEqual({})
+    expect
+      .soft(form.state.fieldMetaBase['people[0].lastName']!.errorMap)
+      .toStrictEqual({})
+    expect
+      .soft(form.state.fieldMetaBase['people[0].lastName']!.errorSourceMap)
+      .toStrictEqual({})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/form-core/tests/FormApi.spec.ts` around lines 433 - 452, The test is
missing assertions for the initial onMount validation state and for the sibling
nested field (people[0].lastName); update the spec around form.replaceFieldValue
to first assert the pre-replacement onMount errors exist on
form.state.fieldMetaBase['people[0].firstName'] and ['people[0].lastName']
(their errorMap/errorSourceMap), then after calling
form.replaceFieldValue('people', 0, {...}) assert both nested fields' meta
(form.state.fieldMetaBase['people[0].firstName'] and
form.state.fieldMetaBase['people[0].lastName']) have empty errorMap and
errorSourceMap, keeping the existing check for form.state.values intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/form-core/tests/FormApi.spec.ts`:
- Line 381: Change the `let fieldErrors: Record<string, string> = {}`
declarations to `const fieldErrors: Record<string, string> = {}` in the test
file where `fieldErrors` is defined (the variable named `fieldErrors` in the
FormApi.spec.ts test cases), since the object is mutated but never reassigned;
update both occurrences so ESLint's prefer-const is satisfied and tests still
mutate properties on the same object instance.
- Around line 433-452: The test is missing assertions for the initial onMount
validation state and for the sibling nested field (people[0].lastName); update
the spec around form.replaceFieldValue to first assert the pre-replacement
onMount errors exist on form.state.fieldMetaBase['people[0].firstName'] and
['people[0].lastName'] (their errorMap/errorSourceMap), then after calling
form.replaceFieldValue('people', 0, {...}) assert both nested fields' meta
(form.state.fieldMetaBase['people[0].firstName'] and
form.state.fieldMetaBase['people[0].lastName']) have empty errorMap and
errorSourceMap, keeping the existing check for form.state.values intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2df90a71-e23a-4748-95c9-062052520838

📥 Commits

Reviewing files that changed from the base of the PR and between 4ada3d6 and 5181d57.

📒 Files selected for processing (2)
  • packages/form-core/tests/FormApi.spec.ts
  • packages/form-core/tests/standardSchemaValidator.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/form-core/tests/standardSchemaValidator.spec.ts

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.

1 participant