Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4755ac7

Browse files
committed
Docs
1 parent c5ba115 commit 4755ac7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

packages/docs/content/api.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,9 @@ schema.parse({
21472147

21482148
### `.superRefine()`
21492149

2150+
2151+
The regular `.refine` API only generates a single issue with a `"custom"` error code, but `.superRefine()` makes it possible to create multiple issues using any of Zod's [internal issue types](https://github.com/colinhacks/zod/blob/main/packages/zod/src/v4/core/errors.ts).
2152+
21502153
<Tabs groupId="lib" items={["Zod", "Zod Mini"]}>
21512154
<Tab value="Zod">
21522155
```ts
@@ -2204,7 +2207,12 @@ const UniqueStringArray = z.array(z.string()).check(
22042207

22052208
### `.check()`
22062209

2210+
<Callout>
2211+
**Note** — The `.check()` API is a more low-level API that's generally more complex than `.superRefine()`. It can be faster in performance-sensitive code paths, but it's also more verbose.
2212+
</Callout>
22072213

2214+
<Accordions>
2215+
<Accordion title="View example">
22082216
The `.refine()` API is syntactic sugar atop a more versatile (and verbose) API called `.check()`. You can use this API to create multiple issues in a single refinement or have full control of the generated issue objects.
22092217

22102218
<Tabs groupId="lib" items={["Zod", "Zod Mini"]}>
@@ -2263,8 +2271,8 @@ const UniqueStringArray = z.array(z.string()).check((ctx) => {
22632271
```
22642272
</Tab>
22652273
</Tabs>
2266-
2267-
The regular `.refine` API only generates issues with a `"custom"` error code, but `.check()` makes it possible to throw other issue types. For more information on Zod's internal issue types, read the [Error customization](./error-customization) docs.
2274+
</Accordion>
2275+
</Accordions>
22682276

22692277
## Pipes
22702278

packages/zod/src/v4/core/api.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,13 +1449,6 @@ export function _custom<O = unknown, I = O>(
14491449
return schema as any;
14501450
}
14511451

1452-
// export function _refine<T>(
1453-
// Class: util.SchemaClass<schemas.$ZodCustom>,
1454-
// fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
1455-
// _params: string | $ZodCustomParams = {}
1456-
// ): checks.$ZodCheck<T> {
1457-
// return _custom(Class, fn, _params);
1458-
// }
14591452
// same as _custom but defaults to abort:false
14601453
export function _refine<O = unknown, I = O>(
14611454
Class: util.SchemaClass<schemas.$ZodCustom>,

0 commit comments

Comments
 (0)