additionalFields type-safety

is it possible to make an additionalField type-safe?

user: {
        additionalFields: {
            permissions: {
                type: "string[]",
                required: true,
                defaultValue: [""], // NOT TYPE-SAFE
                validator: {
                    input: z.enum(["PERMISSION_1", "PERMISSION_2"]).array(),
                    output: z.enum(["PERMISSION_1", "PERMISSION_2"]).array()
                }
            }
        }
    }


right now i have this but defaultValue and the permissions field on the user object is not type-safe and does not have any intellisense
Was this page helpful?