Skip to content

Commit

Permalink
fix(29163): add detection of nested errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Jan 10, 2025
1 parent 5558a33 commit 2e950a7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hivemq-edge/src/frontend/src/components/rjsf/utils/errors.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ErrorSchema, FieldErrors } from '@rjsf/utils'

export const hasNestedError = <T>(props: ErrorSchema<T> | undefined) => {
if (!props) return false
const { __errors, ...rest } = props
for (const subs of Object.keys(rest)) {
const hasError = hasNestedError((props as never)[subs])
if (hasError) return true
}

const errors = (props as FieldErrors).__errors
return errors ? errors.length > 0 : false
}

0 comments on commit 2e950a7

Please sign in to comment.