Skip to content

Commit 84c05d1

Browse files
committed
refactor: Update validations prop in genericForm component
1 parent a3b1df6 commit 84c05d1

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/components/genericForm/index.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ div
33
//- pre(v-html="JSON.stringify(payload, null, 2)")
44
sesame-json-form-renderer(
55
v-model:data="payload.target"
6-
v-model:validations="validations"
6+
v-model:validations="validationsInternal"
77
:schema="schema"
88
:uischema="uischema"
99
)
@@ -33,6 +33,10 @@ const props = defineProps(
3333
type: Object,
3434
required: true,
3535
},
36+
validations: {
37+
type: Object || null,
38+
default: {},
39+
},
3640
}
3741
)
3842
@@ -42,7 +46,12 @@ const { getStateColor, getStateName } = useIdentityStates()
4246
const { handleError } = useErrorHandling()
4347
4448
45-
const validations = ref([])
49+
const validationsInternal = ref(props.validations)
50+
51+
watch(() => props.validations, () => {
52+
validationsInternal.value = props.validations
53+
})
54+
4655
const error = ref(null)
4756
4857
// defineExpose({

src/components/jsonFormRenderer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ function onChange(event: JsonFormsChangeEvent) {
7373
}
7474
7575
const getSchemaValidations = computed(() => {
76-
if (!props.validations || !props.validations[props.schemaName]) {
76+
if (!props.validations || !props.validations) {
7777
return [];
7878
}
7979
const errorObject: ErrorObject[] = [];
80-
let validationList = props.validations[props.schemaName]
80+
let validationList = props.validations
8181
for (const key in validationList) {
8282
errorObject.push({
8383
message: validationList[key],

src/components/jsonFormRendererApi.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template lang="pug">
22
json-forms(
3+
v-if="data"
34
:data="data"
45
:schema="schema"
56
:uischema="uischema"

src/pages/agents/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ div
3333
:payload="payload" ref="form"
3434
:schema="schema"
3535
:uischema="uischema"
36+
v-model:validations="validations"
3637
)
3738
//- sesame-json-form-renderer(
3839
//- v-model:data="payload.target"

0 commit comments

Comments
 (0)