@@ -329,7 +329,7 @@ schema.parse("http://example.com"); // ❌
329329```
330330
331331<Callout >
332- ** Web URLs** — A common use case is validating Web ( ` http ` / ` https ` ) URLs. Here's the recommended schema for doing so:
332+ ** Web URLs** — In many cases, you'll want to validate Web URLs specifically . Here's the recommended schema for doing so:
333333
334334 ``` ts
335335 const httpUrl = z .url ({
@@ -338,7 +338,7 @@ schema.parse("http://example.com"); // ❌
338338 });
339339 ```
340340
341- This restricts the protocol to ` http ` /` https ` and ensures the hostname is a valid domain name with the regex :
341+ This restricts the protocol to ` http ` /` https ` and ensures the hostname is a valid domain name with the ` z.regexes.domain ` regular expression :
342342
343343 ``` ts
344344 / ^ ([a-zA-Z0-9 ] (?:[a-zA-Z0-9 -] {0,61} [a-zA-Z0-9 ] )? \. )+ [a-zA-Z ] {2,} $ /
@@ -947,7 +947,7 @@ Dog.parse({ name: "Yeller", extraKey: true });
947947
948948### ` .catchall() `
949949
950- To defina a * catchall schema* that will be used to validate any unrecognized keys:
950+ To define a * catchall schema* that will be used to validate any unrecognized keys:
951951
952952```
953953const DogWithStrings = z.object({
@@ -1034,11 +1034,11 @@ Starting from this initial schema:
10341034
10351035``` ts z.object
10361036const Recipe = z .object ({
1037- name : z .string (),
1037+ title : z .string (),
10381038 description: z .string ().optional (),
10391039 ingredients: z .array (z .string ()),
10401040});
1041- // { id : string; name : string; ingredients: string[] }
1041+ // { title : string; description? : string | undefined ; ingredients: string[] }
10421042```
10431043To pick certain keys:
10441044
@@ -2495,8 +2495,8 @@ const computeTrimmedLength = MyFunction.implement((input) => {
24952495 return input .trim ().length ;
24962496});
24972497
2498- trimmedLength (" sandwich" ); // => 8
2499- trimmedLength (" asdf " ); // => 4
2498+ computeTrimmedLength (" sandwich" ); // => 8
2499+ computeTrimmedLength (" asdf " ); // => 4
25002500```
25012501
25022502This function will throw a ` ZodError ` if the input is invalid:
0 commit comments