form icon indicating copy to clipboard operation
form copied to clipboard

feat(form-core): add onDynamicListenTo validator option

Open jiji-hoon96 opened this issue 3 weeks ago • 4 comments

Adds support for onDynamicListenTo to enable cross-field dynamic validation.

Changes

  • Added onDynamicListenTo to FieldValidators interface
  • Implemented dynamic cause handling in getLinkedFields method
  • Added unit tests for both sync and async scenarios
// Password confirmation with cross-field validation
<form.Field
  name="confirmPassword"
  validators={{
    onDynamicListenTo: ['password'],  // ← Listen to password changes
    onDynamic: ({ value, fieldApi }) => {
      const password = fieldApi.form.getFieldValue('password')
      return value !== password ? 'Passwords must match' : undefined
    },
  }}
/>

Fixes #1698

jiji-hoon96 avatar Dec 02 '25 01:12 jiji-hoon96

⚠️ No Changeset found

Latest commit: b5afe4d5cead084b5f54ed4e3f1d6b132f5e92f8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Dec 02 '25 01:12 changeset-bot[bot]

View your CI Pipeline Execution ↗ for commit b5afe4d5cead084b5f54ed4e3f1d6b132f5e92f8

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

☁️ Nx Cloud last updated this comment at 2025-12-08 09:30:20 UTC

nx-cloud[bot] avatar Dec 02 '25 01:12 nx-cloud[bot]

More templates

@tanstack/angular-form

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

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

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

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

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

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

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

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

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

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

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

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

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

commit: b5afe4d

pkg-pr-new[bot] avatar Dec 02 '25 01:12 pkg-pr-new[bot]

Codecov Report

:x: Patch coverage is 85.18519% with 8 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 89.51%. Comparing base (6892ed0) to head (b5afe4d). :warning: Report is 88 commits behind head on main.

Files with missing lines Patch % Lines
packages/form-core/src/FieldApi.ts 91.66% 2 Missing and 2 partials :warning:
packages/form-core/src/FieldGroupApi.ts 0.00% 2 Missing :warning:
packages/form-core/src/ValidationLogic.ts 50.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1896      +/-   ##
==========================================
- Coverage   90.35%   89.51%   -0.84%     
==========================================
  Files          38       48      +10     
  Lines        1752     1965     +213     
  Branches      444      499      +55     
==========================================
+ Hits         1583     1759     +176     
- Misses        149      183      +34     
- Partials       20       23       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Dec 02 '25 01:12 codecov[bot]