zod icon indicating copy to clipboard operation
zod copied to clipboard

feat: Add `extract`/`exclude` methods to `ZodEnum`

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

This PR adds two methods to ZodEnum:

  1. extract
  2. exclude

Both work exactly like the TS utility types of the same name.

You call .extract() with values that exist in the enum, and it returns a new one with these values only. The same thing for .exclude() but it returns a new enum without the values you passed in.

Example

Screenshot 2022-12-08 at 5 52 30 AM

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

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
Latest commit 22038ae921ec3cc91c7acac03dc06016536dd36d
Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/63940026ecd696000abc1062
Deploy Preview https://deploy-preview-1652--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 08 '22 08:12 netlify[bot]

I dig it! Sorry I couldn't fit this into 3.20 - had to stop tinkering and just cut a release. The naming is of course perfect. This'll get merged soon.

colinhacks avatar Dec 12 '22 19:12 colinhacks