colinhacks / zod

TypeScript-first schema validation with static type inference
https://zod.dev
MIT License
33.92k stars 1.18k forks source link

fix(ZodDefault): apply default even if inner parse returns undefined #3615

Open jedwards1211 opened 4 months ago

jedwards1211 commented 4 months ago

fix #3614

Note: I can't see any reasonable way to make

    z.union([
      z.literal("").transform(async () => undefined),
      z.string().optional(),
    ])
    .default("inner")
    .default("outer")
    .parse("")

return "outer", it returns "inner".

netlify[bot] commented 4 months ago

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
Latest commit 5e1577153ae607ba31564d1ad095c66b58fb221f
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/668d4ffed838790008951047
Deploy Preview https://deploy-preview-3615--guileless-rolypoly-866f8a.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.