forked from colinhacks/zod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayground.ts
29 lines (22 loc) · 848 Bytes
/
playground.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { z } from "./src";
z;
/* eslint-env mocha */
// const { z, ZodError } = require('zod')
// describe('zod', function () {
// it('cannot deal with circular data structures', function () {
const AnObjectSchema = z.object({ someLiteralProperty: z.literal(1) });
const cicrularObject: any = {
aProperty: "a property",
anotherProperty: 137,
anObjectProperty: { anObjectPropertyProperty: "an object property property" },
anArrayProperty: [
{ anArrayObjectPropertyProperty: "an object property property" },
],
};
cicrularObject.anObjectProperty.cicrularObject = cicrularObject;
cicrularObject.anArrayProperty.push(cicrularObject.anObjectProperty);
const violatingObject = { someLiteralProperty: cicrularObject };
const { success, error } = AnObjectSchema.safeParse(violatingObject);
console.log({ success, error });
// })
// })