/opt/canhelp/node_modules/better-auth/node_modules/zod/src/v4/classic/tests
NameSizeModeActions
anyunknown.test.ts6390644editdlrm
apply.test.ts15090644editdlrm
array.test.ts72480644editdlrm
assignability.test.ts67900644editdlrm
async-parsing.test.ts123110644editdlrm
async-refinements.test.ts18670644editdlrm
base.test.ts1790644editdlrm
bigint.test.ts19560644editdlrm
brand.test.ts35740644editdlrm
catch.test.ts78310644editdlrm
coalesce.test.ts7430644editdlrm
codec-examples.test.ts190300644editdlrm
codec.test.ts188530644editdlrm
coerce.test.ts77360644editdlrm
continuability.test.ts80200644editdlrm
custom.test.ts12150644editdlrm
date.test.ts16710644editdlrm
datetime.test.ts119320644editdlrm
default.test.ts92260644editdlrm
describe-meta-checks.test.ts9650644editdlrm
description.test.ts12940644editdlrm
discriminated-unions.test.ts176650644editdlrm
enum.test.ts84880644editdlrm
error-utils.test.ts137440644editdlrm
error.test.ts195020644editdlrm
file.test.ts26410644editdlrm
firstparty.test.ts30450644editdlrm
fix-json-issue.test.ts7710644editdlrm
from-json-schema.test.ts214980644editdlrm
function.test.ts83440644editdlrm
generics.test.ts21620644editdlrm
hash.test.ts32040644editdlrm
index.test.ts311910644editdlrm
instanceof.test.ts16580644editdlrm
intersection.test.ts55550644editdlrm
json.test.ts33270644editdlrm
lazy.test.ts47560644editdlrm
literal.test.ts30950644editdlrm
map.test.ts76220644editdlrm
nan.test.ts6450644editdlrm
nested-refine.test.ts36230644editdlrm
nonoptional.test.ts28410644editdlrm
nullable.test.ts5910644editdlrm
number.test.ts86440644editdlrm
object.test.ts184810644editdlrm
optional.test.ts73320644editdlrm
partial.test.ts129730644editdlrm
pickomit.test.ts68850644editdlrm
pipe.test.ts23380644editdlrm
prefault.test.ts20630644editdlrm
preprocess.test.ts65220644editdlrm
primitive.test.ts76490644editdlrm
promise.test.ts23240644editdlrm
prototypes.test.ts4980644editdlrm
readonly.test.ts117860644editdlrm
record.test.ts172260644editdlrm
recursive-types.test.ts126930644editdlrm
refine.test.ts156490644editdlrm
registries.test.ts73910644editdlrm
set.test.ts56220644editdlrm
standard-schema.test.ts37700644editdlrm
string-formats.test.ts37000644editdlrm
string.test.ts780690644editdlrm
stringbool.test.ts35360644editdlrm
template-literal.test.ts358940644editdlrm
to-json-schema-methods.test.ts101000644editdlrm
to-json-schema.test.ts786390644editdlrm
transform.test.ts82980644editdlrm
tuple.test.ts55320644editdlrm
union.test.ts59360644editdlrm
url.test.ts4020644editdlrm
validations.test.ts67360644editdlrm
void.test.ts3060644editdlrm
Edit: /opt/canhelp/node_modules/better-auth/node_modules/zod/src/v4/classic/tests/primitive.test.ts (7649B)
import { expect, expectTypeOf, test } from "vitest"; import * as z from "zod/v4"; const literalStringSchema = z.literal("asdf"); const literalNumberSchema = z.literal(12); const literalBooleanSchema = z.literal(true); const literalBigIntSchema = z.literal(BigInt(42)); const stringSchema = z.string(); const numberSchema = z.number(); const bigintSchema = z.bigint(); const booleanSchema = z.boolean(); const dateSchema = z.date(); const symbolSchema = z.symbol(); const nullSchema = z.null(); const undefinedSchema = z.undefined(); const stringSchemaOptional = z.string().optional(); const stringSchemaNullable = z.string().nullable(); const numberSchemaOptional = z.number().optional(); const numberSchemaNullable = z.number().nullable(); const bigintSchemaOptional = z.bigint().optional(); const bigintSchemaNullable = z.bigint().nullable(); const booleanSchemaOptional = z.boolean().optional(); const booleanSchemaNullable = z.boolean().nullable(); const dateSchemaOptional = z.date().optional(); const dateSchemaNullable = z.date().nullable(); const symbolSchemaOptional = z.symbol().optional(); const symbolSchemaNullable = z.symbol().nullable(); test("literal string schema", () => { expect(literalStringSchema.parse("asdf")).toBe("asdf"); expect(() => literalStringSchema.parse("not_asdf")).toThrow(); expect(() => literalStringSchema.parse(123)).toThrow(); expect(() => literalStringSchema.parse(true)).toThrow(); expect(() => literalStringSchema.parse({})).toThrow(); }); test("literal number schema", () => { expect(literalNumberSchema.parse(12)).toBe(12); expect(() => literalNumberSchema.parse(13)).toThrow(); expect(() => literalNumberSchema.parse("foo")).toThrow(); expect(() => literalNumberSchema.parse(true)).toThrow(); expect(() => literalNumberSchema.parse({})).toThrow(); }); test("literal boolean schema", () => { expect(literalBooleanSchema.parse(true)).toBe(true); expect(() => literalBooleanSchema.parse(false)).toThrow(); expect(() => literalBooleanSchema.parse("asdf")).toThrow(); expect(() => literalBooleanSchema.parse(123)).toThrow(); expect(() => literalBooleanSchema.parse({})).toThrow(); }); test("literal bigint schema", () => { expect(literalBigIntSchema.parse(BigInt(42))).toBe(BigInt(42)); expect(() => literalBigIntSchema.parse(BigInt(43))).toThrow(); expect(() => literalBigIntSchema.parse("asdf")).toThrow(); expect(() => literalBigIntSchema.parse(123)).toThrow(); expect(() => literalBigIntSchema.parse({})).toThrow(); }); test("string schema", () => { stringSchema.parse("foo"); expect(() => stringSchema.parse(Math.random())).toThrow(); expect(() => stringSchema.parse(true)).toThrow(); expect(() => stringSchema.parse(undefined)).toThrow(); expect(() => stringSchema.parse(null)).toThrow(); }); test("number schema", () => { numberSchema.parse(Math.random()); expect(() => numberSchema.parse("foo")).toThrow(); expect(() => numberSchema.parse(BigInt(17))).toThrow(); expect(() => numberSchema.parse(true)).toThrow(); expect(() => numberSchema.parse(undefined)).toThrow(); expect(() => numberSchema.parse(null)).toThrow(); }); test("bigint schema", () => { bigintSchema.parse(BigInt(17)); expect(() => bigintSchema.parse("foo")).toThrow(); expect(() => bigintSchema.parse(Math.random())).toThrow(); expect(() => bigintSchema.parse(true)).toThrow(); expect(() => bigintSchema.parse(undefined)).toThrow(); expect(() => bigintSchema.parse(null)).toThrow(); }); test("boolean schema", () => { booleanSchema.parse(true); expect(() => booleanSchema.parse("foo")).toThrow(); expect(() => booleanSchema.parse(Math.random())).toThrow(); expect(() => booleanSchema.parse(undefined)).toThrow(); expect(() => booleanSchema.parse(null)).toThrow(); }); test("date schema", async () => { dateSchema.parse(new Date()); expect(() => dateSchema.parse("foo")).toThrow(); expect(() => dateSchema.parse(Math.random())).toThrow(); expect(() => dateSchema.parse(true)).toThrow(); expect(() => dateSchema.parse(undefined)).toThrow(); expect(() => dateSchema.parse(null)).toThrow(); expect(await dateSchema.safeParseAsync(new Date("invalid"))).toMatchInlineSnapshot(` { "error": [ZodError: [ { "expected": "date", "code": "invalid_type", "received": "Invalid Date", "path": [], "message": "Invalid input: expected date, received Date" } ]], "success": false, } `); }); test("symbol schema", () => { symbolSchema.parse(Symbol("foo")); expect(() => symbolSchema.parse("foo")).toThrow(); expect(() => symbolSchema.parse(Math.random())).toThrow(); expect(() => symbolSchema.parse(true)).toThrow(); expect(() => symbolSchema.parse(new Date())).toThrow(); expect(() => symbolSchema.parse(undefined)).toThrow(); expect(() => symbolSchema.parse(null)).toThrow(); }); test("undefined schema", () => { undefinedSchema.parse(undefined); expect(() => undefinedSchema.parse("foo")).toThrow(); expect(() => undefinedSchema.parse(Math.random())).toThrow(); expect(() => undefinedSchema.parse(true)).toThrow(); expect(() => undefinedSchema.parse(null)).toThrow(); }); test("null schema", () => { nullSchema.parse(null); expect(() => nullSchema.parse("foo")).toThrow(); expect(() => nullSchema.parse(Math.random())).toThrow(); expect(() => nullSchema.parse(true)).toThrow(); expect(() => nullSchema.parse(undefined)).toThrow(); }); test("primitive inference", () => { expectTypeOf>().toEqualTypeOf<"asdf">(); expectTypeOf>().toEqualTypeOf<12>(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); expectTypeOf>().toEqualTypeOf(); }); test("get literal values", () => { expect(literalStringSchema.values).toEqual(new Set(["asdf"])); expect(literalStringSchema._zod.def.values).toEqual(["asdf"]); });