Skip to content

Commit

Permalink
Use new types in validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Jul 11, 2024
1 parent 0cfd6f5 commit e40ea5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
withRequiredCommonProps,
} from 'lib/seam/components/common-props.js'
import { useDevice } from 'lib/seam/devices/use-device.js'
import { getValidationError } from 'lib/seam/error-handlers.js'
import { getValidationError } from 'lib/seam/validation.js'
import { useComponentTelemetry } from 'lib/telemetry/index.js'
import {
AccessCodeForm,
Expand Down
8 changes: 3 additions & 5 deletions src/lib/seam/error-handlers.ts → src/lib/seam/validation.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { type SeamError, SeamMalformedInputError } from 'seamapi'
import { SeamMalformedInputError } from '@seamapi/http/connect'

export const getValidationError = (params: {
error: SeamError
error: Error
property: string
}): string | undefined => {
const { error, property } = params
if (!(error instanceof SeamMalformedInputError)) {
return undefined
}

const propertyErrors = (error.validationErrors[property] ?? {
const propertyErrors = error.validationErrors[property] ?? {
_errors: [],
}) as {
_errors: string[]
}

return propertyErrors._errors[0]
Expand Down

0 comments on commit e40ea5d

Please sign in to comment.