Skip to content

docs(forms): Validate conditional fields where rendered - #126832

Merged
priscilawebdev merged 5 commits into
masterfrom
docs/conditional-form-field-validation
Oct 8, 2026
Merged

priscilawebdev merged 5 commits into
masterfrom
docs/conditional-form-field-validation

Conversation

@priscilawebdev

@priscilawebdev priscilawebdev commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Updating the skill, so it doesn't use superRefine all the time. it is too complex and rarely needed.

@priscilawebdev
priscilawebdev marked this pull request as ready for review October 8, 2026 10:35
@priscilawebdev
priscilawebdev requested a review from a team as a code owner October 8, 2026 10:35
@priscilawebdev
priscilawebdev requested a review from TkDodo October 8, 2026 10:36
@priscilawebdev
priscilawebdev marked this pull request as draft October 8, 2026 10:37
@priscilawebdev
priscilawebdev marked this pull request as ready for review October 8, 2026 10:41
<form.AppField
name="billingEmail"
validators={{
onDynamic: z.string().trim().email('Enter a valid billing email'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The documentation recommends z.string().trim().email(), a deprecated Zod v3 pattern that will cause runtime errors in the project's Zod v4 environment.
Severity: HIGH

Suggested Fix

Update the documentation to recommend the correct Zod v4 pattern for email validation, such as z.string().trim().pipe(z.email()) or simply z.email().

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: .agents/skills/generate-frontend-forms/SKILL.md#L516

Potential issue: The documentation for AI agents in
`.agents/skills/generate-frontend-forms/SKILL.md` and
`.agents/skills/migrate-frontend-forms/SKILL.md` recommends using
`z.string().trim().email()` for form validation. This is a deprecated Zod v3 pattern.
The project uses Zod v4, where `.email()` is not a chainable method after `.string()`.
Code generated by AI agents following this documentation will fail at runtime because
the validation schema will be invalid.

Also affects:

  • .agents/skills/migrate-frontend-forms/SKILL.md:705~705

Did we get this right? 👍 / 👎 to inform future reviews.

showBilling ? (
<form.AppField
name="billingEmail"
validators={{onDynamic: z.string().trim().email('Enter a valid billing email')}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The skill documentation uses the deprecated z.string().trim().email() pattern for Zod v4, which is inconsistent with the correct .pipe(z.email(...)) pattern used elsewhere.
Severity: LOW

Suggested Fix

Update the example in the skill documentation to use the correct Zod v4 pattern for email validation with transformations. Change validators={{onDynamic: z.string().trim().email('Enter a valid billing email')}} to validators={{onDynamic: z.string().trim().pipe(z.email('Enter a valid billing email'))}} to align with best practices.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: .agents/skills/migrate-frontend-forms/SKILL.md#L705

Potential issue: The skill documentation in
`.agents/skills/migrate-frontend-forms/SKILL.md` provides an example using
`z.string().trim().email('Enter a valid billing email')`. This is a deprecated pattern
in Zod v4. The correct approach for chaining transformations like `trim()` with email
validation is to use `.pipe()`, for example: `z.string().trim().pipe(z.email(...))`.
Using the deprecated pattern will lead AI agents to generate incorrect code that
contradicts the project's established practices, as seen in production code like
`objectStorage.tsx`.

@priscilawebdev
priscilawebdev merged commit 9659fed into master Oct 8, 2026
60 checks passed
@priscilawebdev
priscilawebdev deleted the docs/conditional-form-field-validation branch October 8, 2026 12:18
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