Skip to content

Commit 06e9782

Browse files
committed
Tweak URL docs. Closes #4959
1 parent 13a6b4d commit 06e9782

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

packages/docs/content/api.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ const schema = z.url();
317317
schema.parse("https://example.com"); //
318318
schema.parse("http://localhost"); //
319319
schema.parse("mailto:[email protected]"); //
320-
schema.parse("sup"); //
321320
```
322321

323322
As you can see this is quite permissive. Internally this uses the `new URL()` constructor to validate inputs; this behavior may differ across platforms and runtimes but it's the mostly rigorous way to validate URIs/URLs on any given JS runtime/engine.

play.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,3 @@
11
import * as z from "zod";
22

3-
const NodeBase = z.object({
4-
id: z.string(),
5-
get children() {
6-
console.log("accessed");
7-
return z.array(Node).optional();
8-
},
9-
});
10-
11-
// typed as any
12-
console.log("nodeone");
13-
const NodeOne = NodeBase.extend({
14-
name: z.literal("nodeOne"),
15-
// if this is commented out, NodeTwo becomes any
16-
get children() {
17-
return z.array(Node);
18-
},
19-
});
20-
21-
const NodeTwo = NodeBase.extend({
22-
name: z.literal("nodeTwo"),
23-
get children() {
24-
return z.array(Node);
25-
},
26-
});
27-
28-
const Node = z.union([NodeOne, NodeTwo]);
29-
30-
z.object;
3+
console.log(z.url().parse("sup")); // ❌

0 commit comments

Comments
 (0)