timdeschryver / zod-fixture

Creating fixtures based on zod schemas
https://zod-fixture.timdeschryver.dev/
MIT License
121 stars 10 forks source link

feat: Optional Generator Schema #80

Closed THEtheChad closed 1 year ago

THEtheChad commented 1 year ago

This is a new proposal to make generator schemas optional.

Generator({
  output: () => 'everything matched'
})

In the case where a schema is not provided, the type signatures of the checks are no longer known. The checks util has been updated to reflect this and now returns unknown in that scenario. It's an exercise for the user to define what that shape should be.

Generator({
  output: ({ transform, def }) => {
    const checks = tranform.utils.checks(def.checks)
    const max = checks.find('max') // this is now unknown because the Zod type is unknown.
  }
})
vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
zod-fixture ✅ Ready (Inspect) Visit Preview Jul 22, 2023 8:00pm
github-actions[bot] commented 1 year ago

:tada: This PR is included in version 2.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: