Skip to content

Commit 84fd18b

Browse files
committed
feat: add ValidationException
1 parent b1a3684 commit 84fd18b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/exception.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import extractStack from 'extract-stack';
66
import { err, errAsync, Result, ResultAsync } from 'neverthrow';
77
import stringifyObject from 'stringify-object';
88
import type { IsNever, RequiredKeysOf } from 'type-fest';
9+
import type { z } from 'zod';
910

1011
import { objectify } from './object.js';
1112
import { indentLines } from './string.js';
@@ -197,6 +198,11 @@ const { OutOfRangeException } = new ExceptionBuilder()
197198
})
198199
.build();
199200

201+
export const { ValidationException } = new ExceptionBuilder()
202+
.setOptionsType<{ details: { data: unknown; issues: z.ZodIssue[] } }>()
203+
.setParams({ message: 'Zod schema validation failed', name: 'ValidationException' })
204+
.build();
205+
200206
export type {
201207
ExceptionConstructor,
202208
ExceptionConstructorArgs,

0 commit comments

Comments
 (0)