zod icon indicating copy to clipboard operation
zod copied to clipboard

feat: Add `unwrapDeep` to `ZodOptional` and `ZodNullable`

Open santosmarco-caribou opened this issue 2 years ago • 1 comments

This PR adds the unwrapDeep method to both ZodOptionals and ZodNullables, which recursively unwraps the schema in case of multiple calls to .optional() or .nullable().

I understand that this will have more impact on the library itself than on the end users, for example, we can now use these methods:

  1. on the deepPartial method of ZodObject; or
  2. to possibly create a deepPartial on ZodTuples in the future; or
  3. to improve ZodUnion by unwrapping the unnecessarily chained optionals/nullables prior to parsing.

Anyway, it doesn't hurt to expose these methods too.

santosmarco-caribou avatar Dec 16 '22 12:12 santosmarco-caribou

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
Latest commit bcf0fba4cdb527a217b4b0e79200f58528b13465
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/639c632ccf9a710008e37b75
Deploy Preview https://deploy-preview-1708--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 settings.

netlify[bot] avatar Dec 16 '22 12:12 netlify[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 10 '23 00:05 stale[bot]