Hi, I am trying to rewrite this TypeScript attribute as Malli schema:
oneOf: Array<{
/**
* The enum value.
*/
const: string;
/**
* Display label for this option.
*/
title: string;
}>;
What I wrote:
:oneOf [:vector {;; The enum value.
:const :string
;; Display label for this option.
:title :string}]
Does it look wrong to anyone?malli.core/schema didn't error out on this. Should the the thing after :vector be [:map ...]?
pardon me, as I'm not particularly familiar with typescript-
do you want :oneOf to be a vector of maps?
Yes, a vector of maps of those attributes.
i see, then i think the equivalent would be
[:vector
[:map
[:const :string] ;; If this actually is an enum you can use `[:enum X Y Z]`
[:title :string]]]I eventually got an exception from malli.core/schema on that definition, so it's [:map ...]. @sludwig.dev Yes, I found the same, thanks!
:^) 👍 the reason why the map input above didn't error initially is because malli reads it as an option-map
so it was just "a vector, with some options that i don't know about atm so they just do nothing"
Right, that was treated option map - I couldn't spot that earlier.