Linux websever 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64
Apache/2.4.52 (Ubuntu)
: 192.168.3.70 | : 192.168.1.99
Cant Read [ /etc/named.conf ]
8.1.2-1ubuntu2.23
urlab
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
html /
cqt /
node_modules /
zod /
src /
v3 /
tests /
[ HOME SHELL ]
Name
Size
Permission
Action
Mocker.ts
1.31
KB
-rw-r--r--
all-errors.test.ts
4.64
KB
-rw-r--r--
anyunknown.test.ts
673
B
-rw-r--r--
array.test.ts
1.89
KB
-rw-r--r--
async-parsing.test.ts
12.34
KB
-rw-r--r--
async-refinements.test.ts
1.57
KB
-rw-r--r--
base.test.ts
782
B
-rw-r--r--
bigint.test.ts
1.93
KB
-rw-r--r--
branded.test.ts
1.69
KB
-rw-r--r--
catch.test.ts
6.4
KB
-rw-r--r--
coerce.test.ts
6.49
KB
-rw-r--r--
complex.test.ts
1.87
KB
-rw-r--r--
custom.test.ts
950
B
-rw-r--r--
date.test.ts
983
B
-rw-r--r--
deepmasking.test.ts
5.09
KB
-rw-r--r--
default.test.ts
3.44
KB
-rw-r--r--
description.test.ts
1.29
KB
-rw-r--r--
discriminated-unions.test.ts
8.34
KB
-rw-r--r--
enum.test.ts
2.67
KB
-rw-r--r--
error.test.ts
16.42
KB
-rw-r--r--
firstparty.test.ts
2.33
KB
-rw-r--r--
firstpartyschematypes.test.ts
788
B
-rw-r--r--
function.test.ts
6.42
KB
-rw-r--r--
generics.test.ts
1.49
KB
-rw-r--r--
instanceof.test.ts
1.13
KB
-rw-r--r--
intersection.test.ts
3.02
KB
-rw-r--r--
language-server.source.ts
1.25
KB
-rw-r--r--
language-server.test.ts
8.12
KB
-rw-r--r--
literal.test.ts
1.04
KB
-rw-r--r--
map.test.ts
3.46
KB
-rw-r--r--
masking.test.ts
85
B
-rw-r--r--
mocker.test.ts
389
B
-rw-r--r--
nan.test.ts
587
B
-rw-r--r--
nativeEnum.test.ts
2.29
KB
-rw-r--r--
nullable.test.ts
1.14
KB
-rw-r--r--
number.test.ts
6.22
KB
-rw-r--r--
object-augmentation.test.ts
569
B
-rw-r--r--
object-in-es5-env.test.ts
778
B
-rw-r--r--
object.test.ts
11.5
KB
-rw-r--r--
optional.test.ts
1.19
KB
-rw-r--r--
parseUtil.test.ts
869
B
-rw-r--r--
parser.test.ts
1.1
KB
-rw-r--r--
partials.test.ts
6.83
KB
-rw-r--r--
pickomit.test.ts
3.54
KB
-rw-r--r--
pipeline.test.ts
823
B
-rw-r--r--
preprocess.test.ts
4.42
KB
-rw-r--r--
primitive.test.ts
11.93
KB
-rw-r--r--
promise.test.ts
2.43
KB
-rw-r--r--
readonly.test.ts
7.17
KB
-rw-r--r--
record.test.ts
3.65
KB
-rw-r--r--
recursive.test.ts
3.85
KB
-rw-r--r--
refine.test.ts
7.98
KB
-rw-r--r--
safeparse.test.ts
628
B
-rw-r--r--
set.test.ts
4.68
KB
-rw-r--r--
standard-schema.test.ts
2.53
KB
-rw-r--r--
string.test.ts
64.08
KB
-rw-r--r--
transformer.test.ts
5.55
KB
-rw-r--r--
tuple.test.ts
2.63
KB
-rw-r--r--
unions.test.ts
1.5
KB
-rw-r--r--
validations.test.ts
3.74
KB
-rw-r--r--
void.test.ts
349
B
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : object.test.ts
// @ts-ignore TS6133 import { expect, test } from "vitest"; import * as z from "zod/v3"; import { util } from "../helpers/util.js"; const Test = z.object({ f1: z.number(), f2: z.string().optional(), f3: z.string().nullable(), f4: z.array(z.object({ t: z.union([z.string(), z.boolean()]) })), }); test("object type inference", () => { type TestType = { f1: number; f2?: string | undefined; f3: string | null; f4: { t: string | boolean }[]; }; util.assertEqual<z.TypeOf<typeof Test>, TestType>(true); }); test("unknown throw", () => { const asdf: unknown = 35; expect(() => Test.parse(asdf)).toThrow(); }); test("shape() should return schema of particular key", () => { const f1Schema = Test.shape.f1; const f2Schema = Test.shape.f2; const f3Schema = Test.shape.f3; const f4Schema = Test.shape.f4; expect(f1Schema).toBeInstanceOf(z.ZodNumber); expect(f2Schema).toBeInstanceOf(z.ZodOptional); expect(f3Schema).toBeInstanceOf(z.ZodNullable); expect(f4Schema).toBeInstanceOf(z.ZodArray); }); test("correct parsing", () => { Test.parse({ f1: 12, f2: "string", f3: "string", f4: [ { t: "string", }, ], }); Test.parse({ f1: 12, f3: null, f4: [ { t: false, }, ], }); }); test("incorrect #1", () => { expect(() => Test.parse({} as any)).toThrow(); }); test("nonstrict by default", () => { z.object({ points: z.number() }).parse({ points: 2314, unknown: "asdf", }); }); const data = { points: 2314, unknown: "asdf", }; test("strip by default", () => { const val = z.object({ points: z.number() }).parse(data); expect(val).toEqual({ points: 2314 }); }); test("unknownkeys override", () => { const val = z.object({ points: z.number() }).strict().passthrough().strip().nonstrict().parse(data); expect(val).toEqual(data); }); test("passthrough unknown", () => { const val = z.object({ points: z.number() }).passthrough().parse(data); expect(val).toEqual(data); }); test("strip unknown", () => { const val = z.object({ points: z.number() }).strip().parse(data); expect(val).toEqual({ points: 2314 }); }); test("strict", () => { const val = z.object({ points: z.number() }).strict().safeParse(data); expect(val.success).toEqual(false); }); test("catchall inference", () => { const o1 = z .object({ first: z.string(), }) .catchall(z.number()); const d1 = o1.parse({ first: "asdf", num: 1243 }); util.assertEqual<number, (typeof d1)["asdf"]>(true); util.assertEqual<string, (typeof d1)["first"]>(true); }); test("catchall overrides strict", () => { const o1 = z.object({ first: z.string().optional() }).strict().catchall(z.number()); // should run fine // setting a catchall overrides the unknownKeys behavior o1.parse({ asdf: 1234, }); // should only run catchall validation // against unknown keys o1.parse({ first: "asdf", asdf: 1234, }); }); test("catchall overrides strict", () => { const o1 = z .object({ first: z.string(), }) .strict() .catchall(z.number()); // should run fine // setting a catchall overrides the unknownKeys behavior o1.parse({ first: "asdf", asdf: 1234, }); }); test("test that optional keys are unset", async () => { const SNamedEntity = z.object({ id: z.string(), set: z.string().optional(), unset: z.string().optional(), }); const result = await SNamedEntity.parse({ id: "asdf", set: undefined, }); // eslint-disable-next-line ban/ban expect(Object.keys(result)).toEqual(["id", "set"]); }); test("test catchall parsing", async () => { const result = z.object({ name: z.string() }).catchall(z.number()).parse({ name: "Foo", validExtraKey: 61 }); expect(result).toEqual({ name: "Foo", validExtraKey: 61 }); const result2 = z .object({ name: z.string() }) .catchall(z.number()) .safeParse({ name: "Foo", validExtraKey: 61, invalid: "asdf" }); expect(result2.success).toEqual(false); }); test("test nonexistent keys", async () => { const Schema = z.union([z.object({ a: z.string() }), z.object({ b: z.number() })]); const obj = { a: "A" }; const result = await Schema.spa(obj); // Works with 1.11.10, breaks with 2.0.0-beta.21 expect(result.success).toBe(true); }); test("test async union", async () => { const Schema2 = z.union([ z.object({ ty: z.string(), }), z.object({ ty: z.number(), }), ]); const obj = { ty: "A" }; const result = await Schema2.spa(obj); // Works with 1.11.10, breaks with 2.0.0-beta.21 expect(result.success).toEqual(true); }); test("test inferred merged type", async () => { const asdf = z.object({ a: z.string() }).merge(z.object({ a: z.number() })); type asdf = z.infer<typeof asdf>; util.assertEqual<asdf, { a: number }>(true); }); test("inferred merged object type with optional properties", async () => { const Merged = z .object({ a: z.string(), b: z.string().optional() }) .merge(z.object({ a: z.string().optional(), b: z.string() })); type Merged = z.infer<typeof Merged>; util.assertEqual<Merged, { a?: string; b: string }>(true); // todo // util.assertEqual<Merged, { a?: string; b: string }>(true); }); test("inferred unioned object type with optional properties", async () => { const Unioned = z.union([ z.object({ a: z.string(), b: z.string().optional() }), z.object({ a: z.string().optional(), b: z.string() }), ]); type Unioned = z.infer<typeof Unioned>; util.assertEqual<Unioned, { a: string; b?: string } | { a?: string; b: string }>(true); }); test("inferred enum type", async () => { const Enum = z.object({ a: z.string(), b: z.string().optional() }).keyof(); expect(Enum.Values).toEqual({ a: "a", b: "b", }); expect(Enum.enum).toEqual({ a: "a", b: "b", }); expect(Enum._def.values).toEqual(["a", "b"]); type Enum = z.infer<typeof Enum>; util.assertEqual<Enum, "a" | "b">(true); }); test("inferred partial object type with optional properties", async () => { const Partial = z.object({ a: z.string(), b: z.string().optional() }).partial(); type Partial = z.infer<typeof Partial>; util.assertEqual<Partial, { a?: string; b?: string }>(true); }); test("inferred picked object type with optional properties", async () => { const Picked = z.object({ a: z.string(), b: z.string().optional() }).pick({ b: true }); type Picked = z.infer<typeof Picked>; util.assertEqual<Picked, { b?: string }>(true); }); test("inferred type for unknown/any keys", () => { const myType = z.object({ anyOptional: z.any().optional(), anyRequired: z.any(), unknownOptional: z.unknown().optional(), unknownRequired: z.unknown(), }); type myType = z.infer<typeof myType>; util.assertEqual< myType, { anyOptional?: any; anyRequired?: any; unknownOptional?: unknown; unknownRequired?: unknown; } >(true); }); test("setKey", () => { const base = z.object({ name: z.string() }); const withNewKey = base.setKey("age", z.number()); type withNewKey = z.infer<typeof withNewKey>; util.assertEqual<withNewKey, { name: string; age: number }>(true); withNewKey.parse({ name: "asdf", age: 1234 }); }); test("strictcreate", async () => { const strictObj = z.strictObject({ name: z.string(), }); const syncResult = strictObj.safeParse({ name: "asdf", unexpected: 13 }); expect(syncResult.success).toEqual(false); const asyncResult = await strictObj.spa({ name: "asdf", unexpected: 13 }); expect(asyncResult.success).toEqual(false); }); test("object with refine", async () => { const schema = z .object({ a: z.string().default("foo"), b: z.number(), }) .refine(() => true); expect(schema.parse({ b: 5 })).toEqual({ b: 5, a: "foo" }); const result = await schema.parseAsync({ b: 5 }); expect(result).toEqual({ b: 5, a: "foo" }); }); test("intersection of object with date", async () => { const schema = z.object({ a: z.date(), }); expect(schema.and(schema).parse({ a: new Date(1637353595983) })).toEqual({ a: new Date(1637353595983), }); const result = await schema.parseAsync({ a: new Date(1637353595983) }); expect(result).toEqual({ a: new Date(1637353595983) }); }); test("intersection of object with refine with date", async () => { const schema = z .object({ a: z.date(), }) .refine(() => true); expect(schema.and(schema).parse({ a: new Date(1637353595983) })).toEqual({ a: new Date(1637353595983), }); const result = await schema.parseAsync({ a: new Date(1637353595983) }); expect(result).toEqual({ a: new Date(1637353595983) }); }); test("constructor key", () => { const person = z .object({ name: z.string(), }) .strict(); expect(() => person.parse({ name: "bob dylan", constructor: 61, }) ).toThrow(); }); test("constructor key", () => { const Example = z.object({ prop: z.string(), opt: z.number().optional(), arr: z.string().array(), }); type Example = z.infer<typeof Example>; util.assertEqual<keyof Example, "prop" | "opt" | "arr">(true); }); test("unknownkeys merging", () => { // This one is "strict" const schemaA = z .object({ a: z.string(), }) .strict(); // This one is "strip" const schemaB = z .object({ b: z.string(), }) .catchall(z.string()); const mergedSchema = schemaA.merge(schemaB); type mergedSchema = typeof mergedSchema; util.assertEqual<mergedSchema["_def"]["unknownKeys"], "strip">(true); expect(mergedSchema._def.unknownKeys).toEqual("strip"); util.assertEqual<mergedSchema["_def"]["catchall"], z.ZodString>(true); expect(mergedSchema._def.catchall instanceof z.ZodString).toEqual(true); }); const personToExtend = z.object({ firstName: z.string(), lastName: z.string(), }); test("extend() should return schema with new key", () => { const PersonWithNickname = personToExtend.extend({ nickName: z.string() }); type PersonWithNickname = z.infer<typeof PersonWithNickname>; const expected = { firstName: "f", nickName: "n", lastName: "l" }; const actual = PersonWithNickname.parse(expected); expect(actual).toEqual(expected); util.assertEqual<keyof PersonWithNickname, "firstName" | "lastName" | "nickName">(true); util.assertEqual<PersonWithNickname, { firstName: string; lastName: string; nickName: string }>(true); }); test("extend() should have power to override existing key", () => { const PersonWithNumberAsLastName = personToExtend.extend({ lastName: z.number(), }); type PersonWithNumberAsLastName = z.infer<typeof PersonWithNumberAsLastName>; const expected = { firstName: "f", lastName: 42 }; const actual = PersonWithNumberAsLastName.parse(expected); expect(actual).toEqual(expected); util.assertEqual<PersonWithNumberAsLastName, { firstName: string; lastName: number }>(true); }); test("passthrough index signature", () => { const a = z.object({ a: z.string() }); type a = z.infer<typeof a>; util.assertEqual<{ a: string }, a>(true); const b = a.passthrough(); type b = z.infer<typeof b>; util.assertEqual<{ a: string } & { [k: string]: unknown }, b>(true); }); test("xor", () => { type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }; type XOR<T, U> = T extends object ? (U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : U) : T; type A = { name: string; a: number }; type B = { name: string; b: number }; type C = XOR<A, B>; type Outer = { data: C }; const _Outer: z.ZodType<Outer> = z.object({ data: z.union([z.object({ name: z.string(), a: z.number() }), z.object({ name: z.string(), b: z.number() })]), }); });
Close