Skip to content

Commit

Permalink
fix: set form errors helper
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jul 20, 2023
1 parent 8ab6e84 commit 8cf4fe8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/helpers/formik.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export function setFormErrors(
error: unknown,
setErrors: (errors: object) => void
): void {
if (typeof error !== 'object' ||
error === null ||
!('status' in error) ||
typeof error.status !== 'number' ||
error.status !== 400 ||
!('data' in error) ||
typeof error.data !== 'object' ||
error.data === null
) { throw error; }

setErrors(error.data);
}

0 comments on commit 8cf4fe8

Please sign in to comment.