Skip to content
Discussion options

You must be logged in to vote

I had the same problem. I use this postprocess

const zodFilePath = 'pathToZodGeneratedFile';
processZodFile(zodFilePath);
function processZodFile(filePath: string): void {
  if (!existsSync(filePath)) {
    return;
  }
  let content = readFileSync(filePath, 'utf-8');
  content = content.replace(/\.optional\(\)/g, '.nullish()');
  writeFileSync(filePath, content);
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by melloware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
zod Zod related issue
3 participants