/opt/canhelp/node_modules/better-auth/node_modules/zod/src/v3/tests
NameSizeModeActions
all-errors.test.ts47530644editdlrm
anyunknown.test.ts6730644editdlrm
array.test.ts19390644editdlrm
async-parsing.test.ts126390644editdlrm
async-refinements.test.ts16030644editdlrm
base.test.ts7820644editdlrm
bigint.test.ts19770644editdlrm
branded.test.ts17340644editdlrm
catch.test.ts65500644editdlrm
coerce.test.ts66500644editdlrm
complex.test.ts24970644editdlrm
custom.test.ts9500644editdlrm
date.test.ts9830644editdlrm
deepmasking.test.ts52150644editdlrm
default.test.ts35270644editdlrm
description.test.ts13230644editdlrm
discriminated-unions.test.ts85370644editdlrm
enum.test.ts27370644editdlrm
error.test.ts168120644editdlrm
firstparty.test.ts23910644editdlrm
firstpartyschematypes.test.ts7880644editdlrm
function.test.ts67340644editdlrm
generics.test.ts15230644editdlrm
instanceof.test.ts11540644editdlrm
intersection.test.ts30910644editdlrm
language-server.source.ts12750644editdlrm
language-server.test.ts83180644editdlrm
literal.test.ts10630644editdlrm
map.test.ts35450644editdlrm
masking.test.ts850644editdlrm
mocker.test.ts3890644editdlrm
Mocker.ts13410644editdlrm
nan.test.ts7080644editdlrm
nativeEnum.test.ts23440644editdlrm
nullable.test.ts11720644editdlrm
number.test.ts63730644editdlrm
object-augmentation.test.ts5690644editdlrm
object-in-es5-env.test.ts7780644editdlrm
object.test.ts117600644editdlrm
optional.test.ts12220644editdlrm
parser.test.ts11250644editdlrm
parseUtil.test.ts8690644editdlrm
partials.test.ts69960644editdlrm
pickomit.test.ts36220644editdlrm
pipeline.test.ts8230644editdlrm
preprocess.test.ts45300644editdlrm
primitive.test.ts122150644editdlrm
promise.test.ts24900644editdlrm
readonly.test.ts73390644editdlrm
record.test.ts37350644editdlrm
recursive.test.ts39460644editdlrm
refine.test.ts81720644editdlrm
safeparse.test.ts6280644editdlrm
set.test.ts47880644editdlrm
standard-schema.test.ts25870644editdlrm
string.test.ts656330644editdlrm
transformer.test.ts56870644editdlrm
tuple.test.ts26910644editdlrm
unions.test.ts15400644editdlrm
validations.test.ts38260644editdlrm
void.test.ts3490644editdlrm
Edit: /opt/canhelp/node_modules/better-auth/node_modules/zod/src/v3/tests/pickomit.test.ts (3622B)
// @ts-ignore TS6133 import { expect, test } from "vitest"; import * as z from "zod/v3"; import { util } from "../helpers/util.js"; const fish = z.object({ name: z.string(), age: z.number(), nested: z.object({}), }); test("pick type inference", () => { const nameonlyFish = fish.pick({ name: true }); type nameonlyFish = z.infer; util.assertEqual(true); }); test("pick parse - success", () => { const nameonlyFish = fish.pick({ name: true }); nameonlyFish.parse({ name: "bob" }); // @ts-expect-error checking runtime picks `name` only. const anotherNameonlyFish = fish.pick({ name: true, age: false }); anotherNameonlyFish.parse({ name: "bob" }); }); test("pick parse - fail", () => { fish.pick({ name: true }).parse({ name: "12" } as any); fish.pick({ name: true }).parse({ name: "bob", age: 12 } as any); fish.pick({ age: true }).parse({ age: 12 } as any); const nameonlyFish = fish.pick({ name: true }).strict(); const bad1 = () => nameonlyFish.parse({ name: 12 } as any); const bad2 = () => nameonlyFish.parse({ name: "bob", age: 12 } as any); const bad3 = () => nameonlyFish.parse({ age: 12 } as any); // @ts-expect-error checking runtime picks `name` only. const anotherNameonlyFish = fish.pick({ name: true, age: false }).strict(); const bad4 = () => anotherNameonlyFish.parse({ name: "bob", age: 12 } as any); expect(bad1).toThrow(); expect(bad2).toThrow(); expect(bad3).toThrow(); expect(bad4).toThrow(); }); test("omit type inference", () => { const nonameFish = fish.omit({ name: true }); type nonameFish = z.infer; util.assertEqual(true); }); test("omit parse - success", () => { const nonameFish = fish.omit({ name: true }); nonameFish.parse({ age: 12, nested: {} }); // @ts-expect-error checking runtime omits `name` only. const anotherNonameFish = fish.omit({ name: true, age: false }); anotherNonameFish.parse({ age: 12, nested: {} }); }); test("omit parse - fail", () => { const nonameFish = fish.omit({ name: true }); const bad1 = () => nonameFish.parse({ name: 12 } as any); const bad2 = () => nonameFish.parse({ age: 12 } as any); const bad3 = () => nonameFish.parse({} as any); // @ts-expect-error checking runtime omits `name` only. const anotherNonameFish = fish.omit({ name: true, age: false }); const bad4 = () => anotherNonameFish.parse({ nested: {} } as any); expect(bad1).toThrow(); expect(bad2).toThrow(); expect(bad3).toThrow(); expect(bad4).toThrow(); }); test("nonstrict inference", () => { const laxfish = fish.pick({ name: true }).catchall(z.any()); type laxfish = z.infer; util.assertEqual(true); }); test("nonstrict parsing - pass", () => { const laxfish = fish.passthrough().pick({ name: true }); laxfish.parse({ name: "asdf", whatever: "asdf" }); laxfish.parse({ name: "asdf", age: 12, nested: {} }); }); test("nonstrict parsing - fail", () => { const laxfish = fish.passthrough().pick({ name: true }); const bad = () => laxfish.parse({ whatever: "asdf" } as any); expect(bad).toThrow(); }); test("pick/omit/required/partial - do not allow unknown keys", () => { const schema = z.object({ name: z.string(), age: z.number(), }); // @ts-expect-error schema.pick({ $unknown: true }); // @ts-expect-error schema.omit({ $unknown: true }); // @ts-expect-error schema.required({ $unknown: true }); // @ts-expect-error schema.partial({ $unknown: true }); });