We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bd53ef7 commit 0156b80Copy full SHA for 0156b80
1 file changed
apps/backend/src/helpers/arktype.ts
@@ -4,7 +4,12 @@ import { validator as arktypeValidator } from 'hono-openapi'
4
type arktypeValidatorArguments = Parameters<typeof arktypeValidator>
5
export function customArktypeValidator<Target extends arktypeValidatorArguments[0], Schema extends arktypeValidatorArguments[1]>(target: Target, schema: Schema) {
6
return arktypeValidator(target, schema, (result) => {
7
- if (result.success === false)
8
- throw new DetailedError('Validation failed', { statusCode: 400, detail: JSON.stringify(result.error) })
+ if (result.success === false) {
+ throw new DetailedError('Validation failed', {
9
+ statusCode: 400,
10
+ // Normalizes ArkErrors
11
+ detail: JSON.parse(JSON.stringify(result.error)),
12
+ })
13
+ }
14
})
15
}
0 commit comments