Skip to content

Integrate Zod validation in UI screens as POC #97

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 1 commit into
base: master
Choose a base branch
from

Conversation

amitsingh05667
Copy link
Contributor

Integrating Zod Validation with Schema Generation

Steps to integrate Zod validation:

  1. Install Zod and ts-to-zod:
    npm install zod
    npm install -D ts-to-zod

  2. Generate Zod schemas from TypeScript types:
    Use ts-to-zod CLI to automatically generate Zod schemas from existing TypeScript interfaces/types.
    Example command:
    npx ts-to-zod packages/auth0-acul-js/interfaces/screens/signup.ts ,
    packages/auth0-acul-js/interfaces/screens/signup.zod.ts

  3. Review and customize generated schemas:
    Adjust the generated Zod schemas if needed (e.g., add custom validation messages).

  4. Validate form data on submit using generated schemas:
    Use schema.safeParse(formData) to validate data.

  5. Prevent form submission on validation failure:
    Block submission until all validations pass.

This draft PR includes the initial setup for client-side validation using Zod schemas generated automatically via ts-to-zod.

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