Skip to content

Conversation

crutchcorn
Copy link
Member

@crutchcorn crutchcorn commented Jul 22, 2025

This PR adds in a new (optional) property called validationLogic that allows us to emulate alternative validation methods, like the one from RHF where validation does not occur until the first submission, then it validates on change:

const form = useForm({
    defaultValues: {
        name: '',
    },
    // These are the defaults, but demonstrate how you can change them
    validationLogic: revalidateLogic({mode: "submit", modeAfterSubmission: "change"}),
    validators: {
        onDynamic: z.object({
            name: z.string().min(3, 'Name must be at least 3 characters long'),
        }),
    }
})

The above is React, but will be supported day one in all supported framework adapters.

This is a draft pull request and will not be landing immediately, as it is a substantial internal refactor of our code. Once code is done, we'll need docs for all frameworks

TODO

  • Fix types on core
  • Make types on validator functions more strict
  • Add RHF props for reValidateMode and mode
  • Fix types for React
  • Fix types for Angular
  • Fix types for Vue
  • Fix types for Lit
  • Fix types for Solid
  • Fix types for Svelte
  • Write docs

Copy link

nx-cloud bot commented Jul 22, 2025

View your CI Pipeline Execution ↗ for commit fcb613e

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

☁️ Nx Cloud last updated this comment at 2025-08-04 21:40:43 UTC

Copy link

pkg-pr-new bot commented Aug 3, 2025

More templates

@tanstack/angular-form

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

@tanstack/form-core

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

@tanstack/lit-form

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

@tanstack/react-form

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

@tanstack/solid-form

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

@tanstack/svelte-form

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

@tanstack/vue-form

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

commit: fcb613e

@crutchcorn crutchcorn marked this pull request as ready for review August 4, 2025 07:39
Copy link
Contributor

@LeCarbonator LeCarbonator left a comment

Choose a reason for hiding this comment

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

I like it a lot! Just some minor things that should be cleared up, but it's looking promising!

Copy link

codecov bot commented Aug 4, 2025

Codecov Report

❌ Patch coverage is 90.65421% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.51%. Comparing base (b4388e7) to head (fcb613e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/form-core/src/ValidationLogic.ts 92.15% 4 Missing ⚠️
packages/form-core/src/FormApi.ts 75.00% 3 Missing ⚠️
packages/form-core/src/utils.ts 93.93% 2 Missing ⚠️
packages/react-form/src/useTransform.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1622      +/-   ##
==========================================
+ Coverage   90.38%   90.51%   +0.12%     
==========================================
  Files          36       37       +1     
  Lines        1623     1686      +63     
  Branches      386      421      +35     
==========================================
+ Hits         1467     1526      +59     
- Misses        139      143       +4     
  Partials       17       17              

☔ 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.

@crutchcorn crutchcorn merged commit cca8de7 into main Aug 4, 2025
6 checks passed
@crutchcorn crutchcorn deleted the rhf-validate branch August 4, 2025 21:41
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.

2 participants