Skip to content

Commit 1482d7f

Browse files
committed
add comment to fix: allow json fields to accept objects in edit mode without validation errors
1 parent 17718ae commit 1482d7f

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

adminforth/spa/src/components/ResourceForm.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const columnError = (column: AdminForthResourceColumnCommon) => {
131131
if (column.type === 'json' && !column.isArray?.enabled && currentValues.value[column.name]) {
132132
const value = currentValues.value[column.name];
133133
try {
134+
// add object check to allow json fields to be objects in edit mode without throwing validation error, but still validate if the string is a valid json or not
134135
if (typeof value === 'object') {
135136
JSON.parse(JSON.stringify(value));
136137
}
@@ -289,6 +290,8 @@ onMounted(() => {
289290
}
290291
}
291292
} else if (currentValues.value[column.name]) {
293+
// Todo: reconsider basic issue
294+
// if value is not string, we should stringify it, but object we already stringify in setCurrentValue, so we should not stringify it again to prevent double stringification
292295
if (typeof currentValues.value[column.name] !== 'string') {
293296
currentValues.value[column.name] = JSON.stringify(currentValues.value[column.name], null, 2)
294297
}

0 commit comments

Comments
 (0)