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

fix(deps): update dependency zod to v3 #23

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

Conversation

renovate[bot]
Copy link

@renovate renovate bot commented May 17, 2021

This PR contains the following updates:

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

Release Notes

colinhacks/zod (zod)

v3.24.2

Compare Source

v3.24.1

Compare Source

Commits:

v3.24.0

Compare Source

Implement @standard-schema/spec

This is the first version of Zod to implement the Standard Schema spec. This is a new community effort among several validation library authors to implement a common interface, with the goal of simplifying the process of integrating schema validators with the rest of the ecosystem. Read more about the project and goals here.

z.string().jwt()

Thanks to @​Mokshit06 and @​Cognition-Labs for this contribution!

To verify that a string is a valid 3-part JWT.

z.string().jwt();

⚠️ This does not verify your JWT cryptographically! It merely ensures its in the proper format. Use a library like jsonwebtoken to verify the JWT signature, parse the token, and read the claims.

To constrain the JWT to a specific algorithm:

z.string().jwt({ alg: "RS256" });

z.string().base64url()

Thank you to @​marvinruder!

To complement the JWT validation, Zod 3.24 implements a standalone .base64url() string validation API. (The three elements of JWTs are base64url-encoded JSON strings.)

z.string().base64url()

This functionality is available along the standard z.string().base64() validator added in Zod 3.23.

z.string().cidr()

Thanks to @​wataryooou for their work on this!

A validator for CIDR notation for specifying IP address ranges, e.g. 192.24.12.0/22.

z.string().cidr()

To specify an IP version:

z.string().cidr({ version: "v4" })
z.string().cidr({ version: "v6" })

View the full diff from 3.23.8: colinhacks/zod@v3.23.8...v3.24.0

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:

v3.21.4

Compare Source

Commits:

v3.21.3

Compare Source

Commits:

v3.21.2

Compare Source

Commits:

  • b276d71 Improve typings in generics
  • 4d016b7 Improve type inference in generics
  • f9895ab Improve types inside generic functions
  • ac0135e Pass input into catchValue

v3.21.1

Compare Source

Features

Support for ULID validation

z.string().ulid();

Commits:

v3.21.0

Compare Source

Features

z.string().emoji()

Thanks @​joseph-lozano for https://github.com/colinhacks/zod/pull/2045! To validate that all characters in a string are emoji:

z.string().emoji()

...if that's something you want to do for some reason.

z.string().cuid2()

Thanks @​joulev for https://github.com/colinhacks/zod/pull/1813! To validate CUIDv2:

z.string().cuid2()
z.string().ip()

Thanks @​fvckDesa for https://github.com/colinhacks/zod/pull/2066. To validate that a string is a valid IP address:

const v4IP = "122.122.122.122";
const v6IP = "6097:adfa:6f0b:220d:db08:5021:6191:7990";

// matches both IPv4 and IPv6 by default
const ipSchema = z.string().ip();
ipSchema.parse(v4IP) //  pass
ipSchema.parse(v6IP) //  pass

To specify a particular version:

const ipv4Schema = z.string().ip({ version: "v4" });
const ipv6Schema = z.string().ip({ version: "v6" });
z.bigint().{gt|gte|lt|lte}()

Thanks @​igalklebanov for #1711! ZodBigInt gets the same set of methods found on ZodNumber:

z.bigint().gt(BigInt(5));
z.bigint().gte(BigInt(5));
z.bigint().lt(BigInt(5));
z.bigint().lte(BigInt(5));
z.bigint().positive();
z.bigint().negative();
z.bigint().nonnegative();
z.bigint().nonpositive();
z.bigint().multipleOf(BigInt(5));
z.enum(...).extract() and z.enum(...).exclude()

Thanks @​santosmarco-caribou for https://github.com/colinhacks/zod/pull/1652! To add or remove elements from a ZodEnum:

const FoodEnum = z.enum(["Pasta", "Pizza", "Tacos", "Burgers", "Salad"]);
const ItalianEnum = FoodEnum.extract(["Pasta", "Pizza"]); // ZodEnum<["Pasta", "Pizza"]>
const UnhealthyEnum = FoodEnum.exclude(["Salad"]); // ZodEnum<["Pasta", "Pizza", "Tacos", "Burgers"]>

This API is inspired by the Exclude and Extract TypeScript built-ins.

Pass a f

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 was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/zod-3.x branch 3 times, most recently from c1de3d9 to e802757 Compare May 26, 2021 02:49
@renovate renovate bot force-pushed the renovate/zod-3.x branch from e802757 to b0f3fdb Compare June 13, 2021 03:45
@renovate renovate bot force-pushed the renovate/zod-3.x branch 6 times, most recently from 9416b5c to ffab395 Compare July 6, 2021 22:33
@renovate renovate bot force-pushed the renovate/zod-3.x branch from ffab395 to 027bb64 Compare October 18, 2021 15:24
@renovate renovate bot force-pushed the renovate/zod-3.x branch from 027bb64 to 63599b0 Compare March 7, 2022 16:41
@renovate renovate bot force-pushed the renovate/zod-3.x branch from 63599b0 to cdb2471 Compare March 26, 2022 15:51
@renovate renovate bot force-pushed the renovate/zod-3.x branch from cdb2471 to 9a29af7 Compare April 24, 2022 18:34
@renovate renovate bot force-pushed the renovate/zod-3.x branch from 9a29af7 to 50f150f Compare May 16, 2022 00:07
@renovate renovate bot force-pushed the renovate/zod-3.x branch from 50f150f to 2e0de2a Compare June 18, 2022 18:32
@renovate renovate bot force-pushed the renovate/zod-3.x branch from 2e0de2a to 2249da6 Compare September 25, 2022 10:47
@renovate renovate bot force-pushed the renovate/zod-3.x branch from 2249da6 to 296bbad Compare March 16, 2023 09:41
@renovate renovate bot force-pushed the renovate/zod-3.x branch 3 times, most recently from 30f7cd3 to 26f0a4d Compare August 19, 2023 04:47
@renovate renovate bot force-pushed the renovate/zod-3.x branch 2 times, most recently from 6eb0b1c to 92eabb2 Compare October 5, 2023 02:05
@renovate renovate bot force-pushed the renovate/zod-3.x branch from 92eabb2 to f3ccaa5 Compare April 19, 2024 01:50
Copy link

cr-gpt bot commented Apr 19, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from f3ccaa5 to 046050d Compare April 22, 2024 01:02
Copy link

cr-gpt bot commented Apr 22, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from 046050d to 764baa1 Compare April 23, 2024 00:10
Copy link

cr-gpt bot commented Apr 23, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from 764baa1 to 69246f9 Compare April 23, 2024 20:21
Copy link

cr-gpt bot commented Apr 23, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from 69246f9 to d9ef879 Compare April 29, 2024 20:46
Copy link

cr-gpt bot commented Apr 29, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from d9ef879 to d01e0a0 Compare May 3, 2024 03:22
Copy link

cr-gpt bot commented May 3, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from d01e0a0 to daf16f4 Compare May 7, 2024 22:06
Copy link

cr-gpt bot commented May 7, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from daf16f4 to aec057f Compare May 8, 2024 20:39
Copy link

cr-gpt bot commented May 8, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from aec057f to 9ea9786 Compare December 10, 2024 08:59
Copy link

cr-gpt bot commented Dec 10, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from 9ea9786 to 5ca98e5 Compare December 11, 2024 02:32
Copy link

cr-gpt bot commented Dec 11, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@renovate renovate bot force-pushed the renovate/zod-3.x branch from 5ca98e5 to bd769f2 Compare February 12, 2025 03:24
Copy link

cr-gpt bot commented Feb 12, 2025

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

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