1
1
mirror of https://github.com/theoludwig/p61-project.git synced 2024-07-17 07:00:12 +02:00
p61-project/utils/zod.ts

11 lines
267 B
TypeScript
Raw Normal View History

2024-03-24 23:41:23 +01:00
import type { ZodError } from "zod"
export const getErrorsFieldsFromZodError = <T>(
error: ZodError<T>,
): Array<keyof T> => {
2024-05-02 01:08:27 +02:00
const fields = Object.keys(error.format()) as Array<keyof T>
return fields.filter((field) => {
return field !== "_errors"
})
2024-03-24 23:41:23 +01:00
}