Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency zod to v3.23.8 #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Aug 14, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
zod (source) 3.21.4 -> 3.23.8 age adoption passing confidence

Release Notes

colinhacks/zod (zod)

v3.23.8

Compare Source

Commits:

v3.23.7

Compare Source

v3.23.6

Compare Source

v3.23.5

Compare Source

v3.23.4

Compare Source

Commits:

v3.23.3

Compare Source

v3.23.2

Compare Source

Commits:

v3.23.1

Compare Source

v3.23.0

Compare Source

Zod 3.23 is now available. This is the final 3.x release before Zod 4.0. To try it out:

npm install zod

Features

z.string().date()

Zod can now validate ISO 8601 date strings. Thanks @​igalklebanov! https://github.com/colinhacks/zod/pull/1766

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://github.com/colinhacks/zod/pull/1766

const schema = z.string().time();
schema.parse("12:00:00"); // OK

You can specify sub-second precision using the precision option:

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://github.com/colinhacks/zod/pull/3265

const schema = z.string().duration();
schema.parse("P3Y6M4DT12H30M5S"); // OK
Improvements to z.string().datetime()

Thanks @​bchrobot https://github.com/colinhacks/zod/pull/2522

You can now allow unqualified (timezone-less) datetimes using the local: true flag.

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://github.com/colinhacks/zod/pull/3391

z.string().base64()

Zod can now validate base64 strings. Thanks @​StefanTerdell! https://github.com/colinhacks/zod/pull/3047

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
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

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

+  | ZodPipeline<any, any>
+  | ZodReadonly<any>
+  | 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.

- class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {}
+ class ZodType<Output = unknown, Def extends ZodTypeDef = ZodTypeDef, Input = unknown> {}
Unrecognized keys in .pick() and .omit()

This version fixes a bug where unknown keys were accidentally accepted in .pick() and omit(). This has been fixed, which could cause compiler errors in some user code. https://github.com/colinhacks/zod/pull/3255

z.object({ 
  name: z.string() 
}).pick({
  notAKey: true // no longer allowed
})

Bugfixes and performance

Docs and ecosystem

New Contributors

Full Changelog: colinhacks/zod@v3.22.4...v3.23.0

v3.22.5

Compare Source

v3.22.4

Compare Source

Commits:

v3.22.3

Compare Source

Commits:

v3.22.2

Compare Source

Commits:

v3.22.1

Compare Source

Commits:

Fix handing of this in ZodFunction schemas. The parse logic for function schemas now requires the Reflect API.

const methodObject = z.object({
  property: z.number(),
  method: z.function().args(z.string()).returns(z.number()),
});
const methodInstance = {
  property: 3,
  method: function (s: string) {
    return s.length + this.property;
  },
};
const parsed = methodObject.parse(methodInstance);
parsed.method("length=8"); // => 11 (8 length + 3 property)

v3.22.0

Compare Source

ZodReadonly

This release introduces ZodReadonly and the .readonly() method on ZodType.

Calling .readonly() on any schema returns a ZodReadonly instance that wraps the original schema. The new schema parses all inputs using the original schema, then calls Object.freeze() on the result. The inferred type is also marked as readonly.

const schema = z.object({ name: string }).readonly();
type schema = z.infer<typeof schema>;
// Readonly<{name: string}>

const result = schema.parse({ name: "fido" });
result.name = "simba"; // error

The inferred type uses TypeScript's built-in readonly types when relevant.

z.array(z.string()).readonly();
// readonly string[]

z.tuple([z.string(), z.number()]).readonly();
// readonly [string, number]

z.map(z.string(), z.date()).readonly();
// ReadonlyMap<string, Date>

z.set(z.string()).readonly();
// ReadonlySet<Promise<string>>

Commits:


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

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.

@renovate renovate bot changed the title Update dependency zod to v3.22.0 Update dependency zod to v3.22.1 Aug 15, 2023
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 927e2ae to ca239ea Compare August 15, 2023 23:34
@renovate renovate bot changed the title Update dependency zod to v3.22.1 Update dependency zod to v3.22.2 Aug 19, 2023
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from ca239ea to 0d13f68 Compare August 19, 2023 01:46
@renovate renovate bot changed the title Update dependency zod to v3.22.2 Update dependency zod to v3.22.3 Oct 3, 2023
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 0d13f68 to 3f60a2b Compare October 3, 2023 18:54
@renovate renovate bot changed the title Update dependency zod to v3.22.3 Update dependency zod to v3.22.4 Oct 5, 2023
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 3f60a2b to 5a43ada Compare October 5, 2023 01:55
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 5a43ada to ecaf136 Compare April 19, 2024 02:20
@renovate renovate bot changed the title Update dependency zod to v3.22.4 Update dependency zod to v3.22.5 Apr 19, 2024
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from ecaf136 to 4076f8c Compare April 21, 2024 23:23
@renovate renovate bot changed the title Update dependency zod to v3.22.5 Update dependency zod to v3.23.0 Apr 21, 2024
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 4076f8c to 9e5748d Compare April 23, 2024 02:09
@renovate renovate bot changed the title Update dependency zod to v3.23.0 Update dependency zod to v3.23.3 Apr 23, 2024
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 9e5748d to 7b7ad5b Compare April 23, 2024 18:40
@renovate renovate bot changed the title Update dependency zod to v3.23.3 Update dependency zod to v3.23.4 Apr 23, 2024
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 7b7ad5b to 37030c7 Compare April 29, 2024 22:51
@renovate renovate bot changed the title Update dependency zod to v3.23.4 Update dependency zod to v3.23.5 Apr 29, 2024
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 37030c7 to 164f569 Compare May 3, 2024 03:51
@renovate renovate bot changed the title Update dependency zod to v3.23.5 Update dependency zod to v3.23.6 May 3, 2024
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from 164f569 to f40ccc8 Compare May 7, 2024 21:03
@renovate renovate bot changed the title Update dependency zod to v3.23.6 Update dependency zod to v3.23.7 May 7, 2024
@renovate renovate bot force-pushed the renovate/zod-3.x-lockfile branch from f40ccc8 to ad6969c Compare May 8, 2024 21:49
@renovate renovate bot changed the title Update dependency zod to v3.23.7 Update dependency zod to v3.23.8 May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants