Skip to content
Snippets Groups Projects
Commit 5a163ab9 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

refactor: handle invalid FormGroup errors gracefully

parent 9925e086
Branches
No related tags found
No related merge requests found
...@@ -37,14 +37,14 @@ import { useI18n } from '@/i18n' ...@@ -37,14 +37,14 @@ import { useI18n } from '@/i18n'
defineOptions({ compatConfig: { MODE: 3 } }) defineOptions({ compatConfig: { MODE: 3 } })
type Error = { type Error = {
code: string code?: string
message?: string message?: string
} }
const props = defineProps<{ const props = defineProps<{
label?: string label?: string
customControl?: boolean customControl?: boolean
errors?: undefined | Error[] errors?: undefined | (Error | undefined | null)[]
withEditButton?: boolean withEditButton?: boolean
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
...@@ -55,7 +55,7 @@ const { t } = useI18n() ...@@ -55,7 +55,7 @@ const { t } = useI18n()
const formGroupClass = inject('formGroupClass', undefined) const formGroupClass = inject('formGroupClass', undefined)
const id = useId('form-group-control') const id = useId('form-group-control')
const errorsId = useId('form-group-errors') const errorsId = useId('form-group-errors')
const errorList = computed<Error[]>(() => props.errors ?? []) const errorList = computed<Error[]>(() => (props.errors ?? []).filter((e): e is Error => !!e))
const hasErrors = computed(() => errorList.value.length > 0) const hasErrors = computed(() => errorList.value.length > 0)
const controlAttributes = computed(() => ({ const controlAttributes = computed(() => ({
class: [ class: [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment