Skip to content
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

How to convert 'string' to .string().min(1) but not with 'string | null' #80

Closed
Mattchine opened this issue May 4, 2022 · 1 comment

Comments

@Mattchine
Copy link

Feature description

I would like to convert all my string to z.string().min(1) automatically and not from jsDoc. Since my ts file is also auto-generated from somewhere else (rust ts-rs).

Input

// typescript type or interface causing the output
export interface DefaultMin {
  pureS: string;
  nullableS: string | null;
  optionalS?: string;
}

Output

// Expected Zod schemas
export const dafaultMinSchema = z.object({
  pureS: z.string().min(1),
  nullableS: z.string().nullable(),
  optionalS?: z.string().optional(),
})
@Mattchine
Copy link
Author

I implemented adding docstring from ts-rs instead, as mentioned above.

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

No branches or pull requests

1 participant