diff --git a/ui/src/lib/types.ts b/ui/src/lib/types.ts index 3f72d08..f43d6fc 100644 --- a/ui/src/lib/types.ts +++ b/ui/src/lib/types.ts @@ -1,9 +1,12 @@ import type { Field } from '$lib/model/custom_form'; export function fillUndefinedValues(value: any, spec: Field) { - if (value[spec.id] === undefined) { - if (spec.type == "[]uint8") value[spec.id] = ""; - else if (spec.type.startsWith("[]")) value[spec.id] = []; - else if (spec.type != "string" && !spec.type.startsWith("uint") && !spec.type.startsWith("int") && !spec.type.startsWith("time.Duration")) value[spec.id] = { }; + if (value[spec.id] === undefined && spec.type.length) { + let vartype = spec.type; + if (vartype[0] == "*") vartype = vartype.substring(1); + + if (vartype == "[]uint8") value[spec.id] = ""; + else if (vartype.startsWith("[]")) value[spec.id] = []; + else if (vartype != "string" && !vartype.startsWith("uint") && !vartype.startsWith("int") && vartype != "time.Duration" && vartype != "net.IP") value[spec.id] = { }; } }