timdeschryver / zod-fixture

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

Proper handling of ISO datetimes #15

Closed oekstrand closed 1 year ago

oekstrand commented 1 year ago

We have a schema where a lot of our properties are defined as string().datetime(). The generated strings doesn't validate against Zods schema though. https://zod.dev/?id=iso-datetimes

So if I have a schema like this:

const Schema = z.object({
  created: z.string().datetime()
});

The result is: "created": "created-88a852ee-6b28-46a1-a551-9cdc808d9daf"

Running the tests against that gives an error:

[
  {
    "code": "invalid_string",
    "validation": "datetime",
    "message": "Invalid datetime",
    "path": [
      0,
      "created"
    ]
  }
]
timdeschryver commented 1 year ago

Thanks for bringing this to our attention. This needs to be a new customization, do you want to create a Pull Request for this?

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.9.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 2.0.0-beta.16 :tada:

The release is available on:

Your semantic-release bot :package::rocket: