diff --git a/packages/next-safe-action/src/validation-errors.types.ts b/packages/next-safe-action/src/validation-errors.types.ts index cd24dc9..8051d30 100644 --- a/packages/next-safe-action/src/validation-errors.types.ts +++ b/packages/next-safe-action/src/validation-errors.types.ts @@ -1,21 +1,24 @@ import type { Infer, InferIn, Schema } from "./adapters/types"; import type { Prettify } from "./utils.types"; +// Basic types and arrays. +type NotObject = number | string | boolean | bigint | symbol | null | undefined | any[]; + // Object with an optional list of validation errors. type VEList = Prettify<{ _errors?: string[] }>; // Creates nested schema validation errors type using recursion. type SchemaErrors = { - [K in keyof S]?: S[K] extends object | null | undefined ? Prettify> : VEList; + [K in keyof S]?: S[K] extends NotObject ? VEList : Prettify>; } & {}; /** * Type of the returned object when validation fails. */ export type ValidationErrors = S extends Schema - ? Infer extends object - ? Prettify>> - : VEList + ? Infer extends NotObject + ? VEList + : Prettify>> : undefined; /**