Repository navigation
docs(forms): Validate conditional fields where rendered - #126832
Conversation
| <form.AppField | ||
| name="billingEmail" | ||
| validators={{ | ||
| onDynamic: z.string().trim().email('Enter a valid billing email'), |
There was a problem hiding this comment.
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')}} |
There was a problem hiding this comment.
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`.
Updating the skill, so it doesn't use
superRefineall the time. it is too complex and rarely needed.