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 : transformer.test.ts
// @ts-ignore TS6133 import { expect, test } from "vitest"; import * as z from "zod/v3"; import { util } from "../helpers/util.js"; const stringToNumber = z.string().transform((arg) => Number.parseFloat(arg)); // const numberToString = z // .transformer(z.number()) // .transform((n) => String(n)); const asyncNumberToString = z.number().transform(async (n) => String(n)); test("transform ctx.addIssue with parse", () => { const strs = ["foo", "bar"]; expect(() => { z.string() .transform((data, ctx) => { const i = strs.indexOf(data); if (i === -1) { ctx.addIssue({ code: "custom", message: `${data} is not one of our allowed strings`, }); } return data.length; }) .parse("asdf"); }).toThrow( JSON.stringify( [ { code: "custom", message: "asdf is not one of our allowed strings", path: [], }, ], null, 2 ) ); }); test("transform ctx.addIssue with parseAsync", async () => { const strs = ["foo", "bar"]; const result = await z .string() .transform(async (data, ctx) => { const i = strs.indexOf(data); if (i === -1) { ctx.addIssue({ code: "custom", message: `${data} is not one of our allowed strings`, }); } return data.length; }) .safeParseAsync("asdf"); expect(JSON.parse(JSON.stringify(result))).toEqual({ success: false, error: { issues: [ { code: "custom", message: "asdf is not one of our allowed strings", path: [], }, ], name: "ZodError", }, }); }); test("z.NEVER in transform", () => { const foo = z .number() .optional() .transform((val, ctx) => { if (!val) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: "bad" }); return z.NEVER; } return val; }); type foo = z.infer<typeof foo>; util.assertEqual<foo, number>(true); const arg = foo.safeParse(undefined); if (!arg.success) { expect(arg.error.issues[0].message).toEqual("bad"); } }); test("basic transformations", () => { const r1 = z .string() .transform((data) => data.length) .parse("asdf"); expect(r1).toEqual(4); }); test("coercion", () => { const numToString = z.number().transform((n) => String(n)); const data = z .object({ id: numToString, }) .parse({ id: 5 }); expect(data).toEqual({ id: "5" }); }); test("async coercion", async () => { const numToString = z.number().transform(async (n) => String(n)); const data = await z .object({ id: numToString, }) .parseAsync({ id: 5 }); expect(data).toEqual({ id: "5" }); }); test("sync coercion async error", async () => { expect(() => z .object({ id: asyncNumberToString, }) .parse({ id: 5 }) ).toThrow(); // expect(data).toEqual({ id: '5' }); }); test("default", () => { const data = z.string().default("asdf").parse(undefined); // => "asdf" expect(data).toEqual("asdf"); }); test("dynamic default", () => { const data = z .string() .default(() => "string") .parse(undefined); // => "asdf" expect(data).toEqual("string"); }); test("default when property is null or undefined", () => { const data = z .object({ foo: z.boolean().nullable().default(true), bar: z.boolean().default(true), }) .parse({ foo: null }); expect(data).toEqual({ foo: null, bar: true }); }); test("default with falsy values", () => { const schema = z.object({ emptyStr: z.string().default("def"), zero: z.number().default(5), falseBoolean: z.boolean().default(true), }); const input = { emptyStr: "", zero: 0, falseBoolean: true }; const output = schema.parse(input); // defaults are not supposed to be used expect(output).toEqual(input); }); test("object typing", () => { const t1 = z.object({ stringToNumber, }); type t1 = z.input<typeof t1>; type t2 = z.output<typeof t1>; util.assertEqual<t1, { stringToNumber: string }>(true); util.assertEqual<t2, { stringToNumber: number }>(true); }); test("transform method overloads", () => { const t1 = z.string().transform((val) => val.toUpperCase()); expect(t1.parse("asdf")).toEqual("ASDF"); const t2 = z.string().transform((val) => val.length); expect(t2.parse("asdf")).toEqual(4); }); test("multiple transformers", () => { const doubler = stringToNumber.transform((val) => { return val * 2; }); expect(doubler.parse("5")).toEqual(10); }); test("short circuit on dirty", () => { const schema = z .string() .refine(() => false) .transform((val) => val.toUpperCase()); const result = schema.safeParse("asdf"); expect(result.success).toEqual(false); if (!result.success) { expect(result.error.issues[0].code).toEqual(z.ZodIssueCode.custom); } const result2 = schema.safeParse(1234); expect(result2.success).toEqual(false); if (!result2.success) { expect(result2.error.issues[0].code).toEqual(z.ZodIssueCode.invalid_type); } }); test("async short circuit on dirty", async () => { const schema = z .string() .refine(() => false) .transform((val) => val.toUpperCase()); const result = await schema.spa("asdf"); expect(result.success).toEqual(false); if (!result.success) { expect(result.error.issues[0].code).toEqual(z.ZodIssueCode.custom); } const result2 = await schema.spa(1234); expect(result2.success).toEqual(false); if (!result2.success) { expect(result2.error.issues[0].code).toEqual(z.ZodIssueCode.invalid_type); } });
Close