From a7c2969b9125df0fbfa65e8541a974eeaf53b6a6 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Sun, 26 Feb 2023 12:40:01 -0800 Subject: [PATCH] Update error_handling --- ERROR_HANDLING.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ERROR_HANDLING.md b/ERROR_HANDLING.md index f2806f4ff..7c0604354 100644 --- a/ERROR_HANDLING.md +++ b/ERROR_HANDLING.md @@ -40,20 +40,20 @@ _Every_ ZodIssue has these fields: ## ZodIssueCode -| code | additional fields | -| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| ZodIssueCode.invalid_type | `expected: ZodParsedType`
`received: ZodParsedType`

Jump to [this section](#zodparsedtype) for a breakdown of the possible values of ZodParsedType. | -| ZodIssueCode.unrecognized_keys | `keys: string[]`
The list of unrecognized keys
| -| ZodIssueCode.invalid_union | `unionErrors: ZodError[]`
The errors thrown by each element of the union. | -| ZodIssueCode.invalid_enum_value | `options: string[]`
The set of acceptable string values for this enum. | -| ZodIssueCode.invalid_arguments | `argumentsError: ZodError`
This is a special error code only thrown by a wrapped function returned by `ZodFunction.implement()`. The `argumentsError` property is another ZodError containing the validation error details. | -| ZodIssueCode.invalid_return_type | `returnTypeError: ZodError`
This is a special error code only thrown by a wrapped function returned by `ZodFunction.implement()`. The `returnTypeError` property is another ZodError containing the validation error details. | -| ZodIssueCode.invalid_date | _no additional properties_ | -| ZodIssueCode.invalid_string | `validation: "url" \| "email" \| "uuid"`
Which built-in string validator failed | -| ZodIssueCode.too_small | `type: "string" \| "number" \| "array"`
The type of the data failing validation

`minimum: number`
The expected length/value.

`inclusive: boolean`
Whether the minimum is included in the range of acceptable values.
| -| ZodIssueCode.too_big | `type: "string" \| "number" \| "array"`
The type of the data failing validation

`maximum: number`
The expected length/value.

`inclusive: boolean`
Whether the maximum is included in the range of acceptable values.
| -| ZodIssueCode.not_multiple_of | `multipleOf: number`
The value the number should be a multiple of.
| -| ZodIssueCode.custom | `params: { [k: string]: any }`
This is the error code throw by refinements (unless you are using `superRefine` in which case it's possible to throw issues of any `ZodIssueCode`). You are able to pass in a `params` object here that is available in your custom error maps (see [ZodErrorMap](#Customizing-errors-with-ZodErrorMap) below for details on error maps) | +| code | additional fields | +| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| ZodIssueCode.invalid_type | `expected: ZodParsedType`
`received: ZodParsedType`

Jump to [this section](#zodparsedtype) for a breakdown of the possible values of ZodParsedType. | +| ZodIssueCode.unrecognized_keys | `keys: string[]`
The list of unrecognized keys
| +| ZodIssueCode.invalid_union | `unionErrors: ZodError[]`
The errors thrown by each element of the union. | +| ZodIssueCode.invalid_enum_value | `options: string[]`
The set of acceptable string values for this enum. | +| ZodIssueCode.invalid_arguments | `argumentsError: ZodError`
This is a special error code only thrown by a wrapped function returned by `ZodFunction.implement()`. The `argumentsError` property is another ZodError containing the validation error details. | +| ZodIssueCode.invalid_return_type | `returnTypeError: ZodError`
This is a special error code only thrown by a wrapped function returned by `ZodFunction.implement()`. The `returnTypeError` property is another ZodError containing the validation error details. | +| ZodIssueCode.invalid_date | _no additional properties_ | +| ZodIssueCode.invalid_string | `validation: "url" \| "email" \| "uuid"`
Which built-in string validator failed | +| ZodIssueCode.too_small | `type: "string" \| "number" \| "array" \| "set" \| "date"`
The type of the data failing validation

`minimum: number`
The expected length/value.

`inclusive: boolean`
Whether the minimum is included in the range of acceptable values.

`exact: boolean`
Whether the size/length is constrained to be an exact value (used to produce more readable error messages).
| +| ZodIssueCode.too_big | `type: "string" \| "number" \| "array" \| "set" \| "date"`
The type of the data failing validation

`maximum: number`
The expected length/value.

`inclusive: boolean`
Whether the maximum is included in the range of acceptable values.

`exact: boolean`
Whether the size/length is constrained to be an exact value (used to produce more readable error messages).
| +| ZodIssueCode.not_multiple_of | `multipleOf: number`
The value the number should be a multiple of.
| +| ZodIssueCode.custom | `params: { [k: string]: any }`
This is the error code throw by refinements (unless you are using `superRefine` in which case it's possible to throw issues of any `ZodIssueCode`). You are able to pass in a `params` object here that is available in your custom error maps (see [ZodErrorMap](#Customizing-errors-with-ZodErrorMap) below for details on error maps) |