arktypea
arktype16mo ago
dibbo

Optional property with const string array

Hello, the following
const x = ["a", "b", "c"] as const;
const myType = type({
  "optional?": type("===", ...x),
});

is giving a
Only required keys may specify default values
error. It's not really clear to me why - I assume the === operator is doing more than what I think.

Is there a way to have an optional property be one of a string array in arktype? Or is what I'm after effectively indexed access expressions? Thanks
GitHub
TypeScript's 1:1 validator, optimized from editor to runtime - Issues · arktypeio/arktype
Was this page helpful?