Comments (1)
There isn't an equivalent of stripUnknown
because Zod doesn't do any data transformation. Like you mentioned, .parse
currently returns the same object you pass in; doing transformation like this would require a big rewrite.
You could use a tool like lodash in conjunction with Animal.shape
(you don't need to call .toJSON
to get the shape) like so:
const parsedAnimal = Animal.parse({ name: 'tommy', kind: 'cat' });
const transformedAnimal = _.pick(parsedAnimal, Object.keys(Animal.shape))
transformedAnimal; // => { name: 'tommy' }
- not tested but it should work
from zod.
Related Issues (20)
- cuid() considers the word corrigendum as a cuid HOT 2
- Nested schema w/ .default doesn't generate the default value if it is used with .optional HOT 1
- Zod validator calls refine and ignoring other validators HOT 4
- Zod Tuple type shows HOT 1
- Zod Lazy - optional recursion HOT 1
- Adding .required does not make returned type have required field HOT 3
- Recursive schema that uses other schemas not working due to incompatible inputs and outputs HOT 2
- Project bottlenecks?
- Zod continues to throw errors while using async refinements with react hook form when zod resolver mode is set to async HOT 1
- Zod is not able to catch decimal point error when it's optional() HOT 1
- The .transform method is throwing errors HOT 1
- .email() does not respect UTF8SMTP Extension standard (which includes öäü aka. Umlaute)
- is there any play support .example?
- Exception handling in transform or safeParse HOT 5
- Typescript declaration file fails to infer type properly HOT 1
- Issue with enum initiated with Array<Something> type HOT 5
- type checking HOT 1
- ZodBigInt#isOptional throws HOT 5
- playground.ts file throws error.
- Different behavior for union() and or() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zod.