colinhacks/zod (zod)
### [`v3.23.4`](https://togithub.com/colinhacks/zod/releases/tag/v3.23.4)
[Compare Source](https://togithub.com/colinhacks/zod/compare/v3.23.3...v3.23.4)
#### Commits:
- [`157b18d`](https://togithub.com/colinhacks/zod/commit/157b18d742c86d85b26a8421af46ad6d6d6b6ea7) Add 3.23 announcement
- [`aedf93f`](https://togithub.com/colinhacks/zod/commit/aedf93f1435a29463d915c3be45b4dcbeefa8cc1) Revert change to default Input
- [`45107f7`](https://togithub.com/colinhacks/zod/commit/45107f7a7230fe48ee24dc37e621422c9dc64ec4) v3.23.4
### [`v3.23.3`](https://togithub.com/colinhacks/zod/compare/v3.23.2...103d2436f85872ca0e0e6247652989cc93d46a39)
[Compare Source](https://togithub.com/colinhacks/zod/compare/v3.23.2...v3.23.3)
### [`v3.23.2`](https://togithub.com/colinhacks/zod/releases/tag/v3.23.2)
[Compare Source](https://togithub.com/colinhacks/zod/compare/v3.23.1...v3.23.2)
#### Commits:
- [`c340558`](https://togithub.com/colinhacks/zod/commit/c340558d14f5222a2ca177e0591463c06cc5edc3) Update protocol
- [`ef588d0`](https://togithub.com/colinhacks/zod/commit/ef588d036f3e98b832796e9a681dbaf097631ea0) Fix t3env
- [`9df70dd`](https://togithub.com/colinhacks/zod/commit/9df70dd71195df951c43f180fbe5e64ea1f835df) 3.23.2
### [`v3.23.1`](https://togithub.com/colinhacks/zod/compare/v3.23.0...2ff5ceb428634de0ea4501495039c05a8e95b60a)
[Compare Source](https://togithub.com/colinhacks/zod/compare/v3.23.0...v3.23.1)
### [`v3.23.0`](https://togithub.com/colinhacks/zod/releases/tag/v3.23.0)
[Compare Source](https://togithub.com/colinhacks/zod/compare/e7a9b9b3033991be6b4225f1be21da39c250bbb0...v3.23.0)
Zod 3.23 is now available. This is the final `3.x` release before Zod 4.0. To try it out:
```sh
npm install zod
```
#### Features
##### `z.string().date()`
Zod can now validate ISO 8601 date strings. Thanks [@igalklebanov](https://togithub.com/igalklebanov)! [https://github.com/colinhacks/zod/pull/1766](https://togithub.com/colinhacks/zod/pull/1766)
```ts
const schema = z.string().date();
schema.parse("2022-01-01"); // OK
```
##### `z.string().time()`
Zod can now validate ISO 8601 time strings. Thanks [@igalklebanov](https://togithub.com/igalklebanov)! [https://github.com/colinhacks/zod/pull/1766](https://togithub.com/colinhacks/zod/pull/1766)
```ts
const schema = z.string().time();
schema.parse("12:00:00"); // OK
```
You can specify sub-second precision using the `precision` option:
```ts
const schema = z.string().time({ precision: 3 });
schema.parse("12:00:00.123"); // OK
schema.parse("12:00:00.123456"); // Error
schema.parse("12:00:00"); // Error
```
##### `z.string().duration()`
Zod can now validate ISO 8601 duration strings. Thanks [@mastermatt](https://togithub.com/mastermatt)! [https://github.com/colinhacks/zod/pull/3265](https://togithub.com/colinhacks/zod/pull/3265)
```ts
const schema = z.string().duration();
schema.parse("P3Y6M4DT12H30M5S"); // OK
```
##### Improvements to `z.string().datetime()`
Thanks [@bchrobot](https://togithub.com/bchrobot) [https://github.com/colinhacks/zod/pull/2522](https://togithub.com/colinhacks/zod/pull/2522)
You can now allow *unqualified* (timezone-less) datetimes using the `local: true` flag.
```ts
const schema = z.string().datetime({ local: true });
schema.parse("2022-01-01T12:00:00"); // OK
```
Plus, Zod now validates the day-of-month correctly to ensure no invalid dates (e.g. February 30th) pass validation. Thanks [@szamanr](https://togithub.com/szamanr)! [https://github.com/colinhacks/zod/pull/3391](https://togithub.com/colinhacks/zod/pull/3391)
##### `z.string().base64()`
Zod can now validate base64 strings. Thanks [@StefanTerdell](https://togithub.com/StefanTerdell)! [https://github.com/colinhacks/zod/pull/3047](https://togithub.com/colinhacks/zod/pull/3047)
```ts
const schema = z.string().base64();
schema.parse("SGVsbG8gV29ybGQ="); // OK
```
##### Improved discriminated unions
The following can now be used as discriminator keys in `z.discriminatedUnion()`:
- `ZodOptional`
- `ZodNullable`
- `ZodReadonly`
- `ZodBranded`
- `ZodCatch`
```ts
const schema = z.discriminatedUnion("type", [
z.object({ type: z.literal("A").optional(), value: z.number() }),
z.object({ type: z.literal("B").nullable(), value: z.string() }),
z.object({ type: z.literal("C").readonly(), value: z.boolean() }),
z.object({ type: z.literal("D").brand<"D">(), value: z.boolean() }),
z.object({ type: z.literal("E").catch("E"), value: z.unknown() }),
]);
```
##### Misc
- feature: allow falsy error message by [@fernandollisboa](https://togithub.com/fernandollisboa) in [https://github.com/colinhacks/zod/pull/3178](https://togithub.com/colinhacks/zod/pull/3178)
- feature: add attribute message to enum validatiion by [@fernandollisboa](https://togithub.com/fernandollisboa) in [https://github.com/colinhacks/zod/pull/3169](https://togithub.com/colinhacks/zod/pull/3169)
#### Breaking changes
There are no breaking changes to the public API of Zod. However some changes can impact ecosystem tools that rely on Zod internals.
##### `ZodFirstPartySchemaTypes`
Three new types have been added to the `ZodFirstPartySchemaTypes` union. This may impact some codegen libraries. [https://github.com/colinhacks/zod/pull/3247](https://togithub.com/colinhacks/zod/pull/3247)
```diff
+ | ZodPipeline
+ | ZodReadonly
+ | ZodSymbol;
```
##### Default generics in `ZodType`
The third argument of the `ZodType` base class now defaults to `unknown`. This makes it easier to define recursive schemas and write generic functions that accept Zod schemas.
```diff
- class ZodType
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
3.22.4
->3.23.4
Release Notes
colinhacks/zod (zod)
### [`v3.23.4`](https://togithub.com/colinhacks/zod/releases/tag/v3.23.4) [Compare Source](https://togithub.com/colinhacks/zod/compare/v3.23.3...v3.23.4) #### Commits: - [`157b18d`](https://togithub.com/colinhacks/zod/commit/157b18d742c86d85b26a8421af46ad6d6d6b6ea7) Add 3.23 announcement - [`aedf93f`](https://togithub.com/colinhacks/zod/commit/aedf93f1435a29463d915c3be45b4dcbeefa8cc1) Revert change to default Input - [`45107f7`](https://togithub.com/colinhacks/zod/commit/45107f7a7230fe48ee24dc37e621422c9dc64ec4) v3.23.4 ### [`v3.23.3`](https://togithub.com/colinhacks/zod/compare/v3.23.2...103d2436f85872ca0e0e6247652989cc93d46a39) [Compare Source](https://togithub.com/colinhacks/zod/compare/v3.23.2...v3.23.3) ### [`v3.23.2`](https://togithub.com/colinhacks/zod/releases/tag/v3.23.2) [Compare Source](https://togithub.com/colinhacks/zod/compare/v3.23.1...v3.23.2) #### Commits: - [`c340558`](https://togithub.com/colinhacks/zod/commit/c340558d14f5222a2ca177e0591463c06cc5edc3) Update protocol - [`ef588d0`](https://togithub.com/colinhacks/zod/commit/ef588d036f3e98b832796e9a681dbaf097631ea0) Fix t3env - [`9df70dd`](https://togithub.com/colinhacks/zod/commit/9df70dd71195df951c43f180fbe5e64ea1f835df) 3.23.2 ### [`v3.23.1`](https://togithub.com/colinhacks/zod/compare/v3.23.0...2ff5ceb428634de0ea4501495039c05a8e95b60a) [Compare Source](https://togithub.com/colinhacks/zod/compare/v3.23.0...v3.23.1) ### [`v3.23.0`](https://togithub.com/colinhacks/zod/releases/tag/v3.23.0) [Compare Source](https://togithub.com/colinhacks/zod/compare/e7a9b9b3033991be6b4225f1be21da39c250bbb0...v3.23.0) Zod 3.23 is now available. This is the final `3.x` release before Zod 4.0. To try it out: ```sh npm install zod ``` #### Features ##### `z.string().date()` Zod can now validate ISO 8601 date strings. Thanks [@igalklebanov](https://togithub.com/igalklebanov)! [https://github.com/colinhacks/zod/pull/1766](https://togithub.com/colinhacks/zod/pull/1766) ```ts const schema = z.string().date(); schema.parse("2022-01-01"); // OK ``` ##### `z.string().time()` Zod can now validate ISO 8601 time strings. Thanks [@igalklebanov](https://togithub.com/igalklebanov)! [https://github.com/colinhacks/zod/pull/1766](https://togithub.com/colinhacks/zod/pull/1766) ```ts const schema = z.string().time(); schema.parse("12:00:00"); // OK ``` You can specify sub-second precision using the `precision` option: ```ts const schema = z.string().time({ precision: 3 }); schema.parse("12:00:00.123"); // OK schema.parse("12:00:00.123456"); // Error schema.parse("12:00:00"); // Error ``` ##### `z.string().duration()` Zod can now validate ISO 8601 duration strings. Thanks [@mastermatt](https://togithub.com/mastermatt)! [https://github.com/colinhacks/zod/pull/3265](https://togithub.com/colinhacks/zod/pull/3265) ```ts const schema = z.string().duration(); schema.parse("P3Y6M4DT12H30M5S"); // OK ``` ##### Improvements to `z.string().datetime()` Thanks [@bchrobot](https://togithub.com/bchrobot) [https://github.com/colinhacks/zod/pull/2522](https://togithub.com/colinhacks/zod/pull/2522) You can now allow *unqualified* (timezone-less) datetimes using the `local: true` flag. ```ts const schema = z.string().datetime({ local: true }); schema.parse("2022-01-01T12:00:00"); // OK ``` Plus, Zod now validates the day-of-month correctly to ensure no invalid dates (e.g. February 30th) pass validation. Thanks [@szamanr](https://togithub.com/szamanr)! [https://github.com/colinhacks/zod/pull/3391](https://togithub.com/colinhacks/zod/pull/3391) ##### `z.string().base64()` Zod can now validate base64 strings. Thanks [@StefanTerdell](https://togithub.com/StefanTerdell)! [https://github.com/colinhacks/zod/pull/3047](https://togithub.com/colinhacks/zod/pull/3047) ```ts const schema = z.string().base64(); schema.parse("SGVsbG8gV29ybGQ="); // OK ``` ##### Improved discriminated unions The following can now be used as discriminator keys in `z.discriminatedUnion()`: - `ZodOptional` - `ZodNullable` - `ZodReadonly` - `ZodBranded` - `ZodCatch` ```ts const schema = z.discriminatedUnion("type", [ z.object({ type: z.literal("A").optional(), value: z.number() }), z.object({ type: z.literal("B").nullable(), value: z.string() }), z.object({ type: z.literal("C").readonly(), value: z.boolean() }), z.object({ type: z.literal("D").brand<"D">(), value: z.boolean() }), z.object({ type: z.literal("E").catch("E"), value: z.unknown() }), ]); ``` ##### Misc - feature: allow falsy error message by [@fernandollisboa](https://togithub.com/fernandollisboa) in [https://github.com/colinhacks/zod/pull/3178](https://togithub.com/colinhacks/zod/pull/3178) - feature: add attribute message to enum validatiion by [@fernandollisboa](https://togithub.com/fernandollisboa) in [https://github.com/colinhacks/zod/pull/3169](https://togithub.com/colinhacks/zod/pull/3169) #### Breaking changes There are no breaking changes to the public API of Zod. However some changes can impact ecosystem tools that rely on Zod internals. ##### `ZodFirstPartySchemaTypes` Three new types have been added to the `ZodFirstPartySchemaTypes` union. This may impact some codegen libraries. [https://github.com/colinhacks/zod/pull/3247](https://togithub.com/colinhacks/zod/pull/3247) ```diff + | ZodPipelineConfiguration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.