Repository navigation
feat(core,ui-react): client-side, schema-derived validation in DocForm and the admin editor (5c) - #45
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 4c69bb9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 59 minutes. View limit details
TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.
|
cursor Bot
pushed a commit
that referenced
this pull request
Nov 6, 2026
…n rehearsal Co-authored-by: jherr <jherr@pobox.com>
cursor
Bot
force-pushed
the
cursor/admin-edit-route-d21e
branch
from
November 6, 2026 14:50
26cdeaf to
2767e37
Compare
cursor
Bot
force-pushed
the
cursor/client-validation-d21e
branch
from
November 6, 2026 14:50
66b3f69 to
095d69c
Compare
jherr
force-pushed
the
cursor/client-validation-d21e
branch
from
November 6, 2026 15:10
095d69c to
4c69bb9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements cms-refactor-plan.md § Phase 5 (5c): client-side, schema-derived validation.
Merge chain: step 23 of 24. Base:
main. Merge it right after #42. The branch ismain3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit095d69c(treebf07ae4).What
Core:
schemaIssues(collection, doc), a new client-safe export (lib/validation.ts).schemaForparse the server's write path runs.requiredon the fields thatshowWhenshows. That walk moved out of the server'scheckFieldRulesinto this shared module, so client and server run one implementation.checkFieldRuleskeeps its issue order and messages.schemaIssuesreturns exactly the server's paths and messages.DocForm/useDocForm.onBlurvalidator. TanStack Form also runs it on submit, so a submit that fails validation never reachesonSubmit, andsubmit()resolvesfalse.errorsfrom the server still take precedence over the form's own messages.validate={false}turns the schema checks off.fieldValidators: { name: fn | false }overrides a single field, andfnreceives that field'sschemaError.fieldErrorsandvalidatorsFor(name).Admin edit route. It gets validation through
DocFormwith no extra wiring. A blocked save shows the existing "Fix the highlighted fields" alert and sends nothing.Fixed on the way, both caught by the base E2E:
FieldInputrendered its control at a different depth with and without an error. So when an error appeared on blur, React remounted the input the user had just moved into, which lost a typed array-item name.Each fix has a unit test that fails with the fix reverted.
Docs and changesets:
schema-issues.md(core, minor);doc-form-validation.md(ui-react, minor).Breaking changes
None in the APIs. Two things change visibly:
FieldInputalways wraps an enabled control in a<div>.How verified
GitHub Actions is out of billing, so everything ran locally.
pnpm install --frozen-lockfiletest:ci(174 tasks)@tanstack/cms-api:test:oxlinttest:dtstest:dialectstest:definitionstest:scriptsAssumptions (conservative defaults where the plan gives none)
validatestays server-side. That covers functions and Standard Schemas, which may use server-only code or be async. The docs show how to run such a rule on the client early withfieldValidators.preValidatehooks aren't visible to the client. A hook that fills a required value would make the client stricter than the server for that field. None of the examples do that, and the opt-outs cover it.fieldValidatorsstill run whenvalidate={false}.Divergence from plan
FieldInputchanged outsideDocForm: an enabled control is now always wrapped.checkFieldRuleswas refactored to share theshowWhen-required walk.Merge chain (local verification, CI down)
This PR's commits are squashed into one commit on the linear merge chain. That commit holds this PR's own changes, resolved against every PR before it, with the integration rehearsal's fixes for this PR applied. No conflicts.
The chain tip's tree is exactly the integration rehearsal plus #46 (
c4e6d7c), and the tip passes the full local suite. I simulated merging every PR in order, with a merge commit or a fast-forward at each step, and every step is clean. A plain squash of the next PR would conflict, because the squash commit isn't an ancestor of the next branch. To squash instead, first rebase the branch's one commit onto the newmain; that rebase is always clean.