Skip to content

Add alternative validation methods #1622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft

Add alternative validation methods #1622

wants to merge 26 commits into from

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: '',
    },
    // In the future, we'll support more options ala: `rhfValidationLogic({mode: "change", reValidateMode: "blur"})`
    validationLogic: rhfValidationLogic,
    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

  • Add form listeners for onDynamic?
  • 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

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

Don't show these notices


View your CI Pipeline Execution ↗ for commit 51b2bae

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

☁️ Nx Cloud last updated this comment at 2025-08-03 07:56:06 UTC

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