-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
40 lines (38 loc) · 1.24 KB
/
index.d.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
30
31
32
33
34
35
36
37
38
39
40
import { ZodError } from 'zod'
/**
* Converts a ZodError to a structured error.
*
* @export
* @param {ZodError} error The Zod error
* @param {ZodStructuredErrorOptions} [options] options
* @return {*} {ZodStructuredError}
*/
export declare function toStructuredError(error: ZodError, options?: ZodStructuredErrorOptions): ZodStructuredError
export type ZodStructuredError = Record<string, string | string[]>
export type ZodStructuredErrorOptions = ZodStructuredErrorOptionsBase & (ZodStructuredErrorOptionsJoin | ZodStructuredErrorOptionsArray)
export type ZodStructuredErrorOptionsArray = {
grouping: 'array'
delimiter?: never
}
export type ZodStructuredErrorOptionsBase = {
/**
* How to handle multiple issues for the same path.
* - `join` (default): join error messages with a delimiter (see `joinDelimiter`)
* - `array`: return an array of error messages
*/
grouping?: 'join' | 'array'
/**
* Delimiter to use when joining multiple issues for the same path
* Default: `; ` (semicolon + space)
*/
joinDelimiter?: string
/**
* Delimiter to use when joining path segments. Default: `.`
*/
pathDelimiter?: string
}
export type ZodStructuredErrorOptionsJoin = {
grouping?: 'join'
delimiter?: string
}
export { }