fawwaz
fawwaz15mo ago

an object with fixed shape but random keys in the table schema

I wanted to ask if it possible to have in the table schema an object with fixed shape but random keys of type string. For example how do represent the below type as table schema. type TableSchema = { name: string; data: { [key: string]: { value: string; }; }; }; Currently the only way I know how to do this, is to set data to type any which can be very annoying as the object get more complex.
2 Replies
Michal Srb
Michal Srb15mo ago
Hey @fawwaz, we don’t have a validator for this type yet. You can use v.any, or switch to an array like v.array(v.object({key: string, value: string}))
fawwaz
fawwazOP15mo ago
that's not a bad idea, thanks @Michal Srb

Did you find this page helpful?