Hello, is it possible to define object keys from enum?
I have enum called Language which contains “sk”, “cs”, “en”
I would like to define object (called name) so that it has to contain key from enum, eg. “cs” and value as string
eg.
"name": {
"cs": "Hello there"
}
generic definition may look like object<Language, string>
thanks
came7o
(melo)
May 7, 2024, 2:43am
2
you can be defined in code, not in a visual interface.
thanks, but that is not ideal for my situation.
i already have hundreds of fields that are “translation aware”, meaning when i add or remove new language i have to update every single field
would be great to just reference enum
Thanks for the feedback, key name referencing enums is not supported but we will think about how to optimize it.
Currently, you can define dynamic key names using the following JSONSchema, set as a schema, and then reference it in the corresponding interface.
{“type”:“object”,“properties”:{“name”:{“type”:“object”,“patternProperties”:{“^(sk|cs|en)$”:{“type”:“string”}},“required”:[“cs”]}},“additionalProperties”:false}.