Skip to content

Conversation

@jiji-hoon96
Copy link
Contributor

@jiji-hoon96 jiji-hoon96 commented Dec 2, 2025

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

- Add onDynamicListenTo to FieldValidators interface
- Implement dynamic cause handling in getLinkedFields method
- Add password/confirmPassword example demonstrating cross-field validation
@changeset-bot
Copy link

changeset-bot bot commented Dec 2, 2025

⚠️ No Changeset found

Latest commit: 5f7b420

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

@nx-cloud
Copy link

nx-cloud bot commented Dec 2, 2025

View your CI Pipeline Execution ↗ for commit 5f7b420

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

☁️ Nx Cloud last updated this comment at 2025-12-03 01:59:42 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 2, 2025

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: 5f7b420

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.78%. Comparing base (6892ed0) to head (5f7b420).
⚠️ Report is 79 commits behind head on main.

Files with missing lines Patch % Lines
packages/form-core/src/FieldApi.ts 93.54% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1896      +/-   ##
==========================================
- Coverage   90.35%   89.78%   -0.57%     
==========================================
  Files          38       46       +8     
  Lines        1752     1939     +187     
  Branches      444      490      +46     
==========================================
+ Hits         1583     1741     +158     
- Misses        149      177      +28     
- Partials       20       21       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

jiji-hoon96 and others added 4 commits December 3, 2025 10:20
- Add test for onDynamic cross-field validation with onDynamicListenTo
- Add test for onDynamicAsync cross-field validation with onDynamicListenTo
- Fix getLinkedFields to return validator cause for each linked field
- Add 'dynamic' case to defaultValidationLogic
- Clear dynamic errors when running change/blur validation
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.

onDynamicListenTo does not exist

1 participant