malli

Shantanu Kumar 2026-06-04T15:31:45.397509Z

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?

Shantanu Kumar 2026-06-04T15:37:22.980429Z

malli.core/schema didn't error out on this. Should the the thing after :vector be [:map ...]?

Samuel Ludwig 2026-06-04T15:44:59.298479Z

pardon me, as I'm not particularly familiar with typescript- do you want :oneOf to be a vector of maps?

Shantanu Kumar 2026-06-04T15:45:41.832059Z

Yes, a vector of maps of those attributes.

Samuel Ludwig 2026-06-04T15:47:44.578329Z

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]]]

Shantanu Kumar 2026-06-04T15:48:31.024189Z

I eventually got an exception from malli.core/schema on that definition, so it's [:map ...]. @sludwig.dev Yes, I found the same, thanks!

Samuel Ludwig 2026-06-04T15:49:32.616949Z

:^) 👍 the reason why the map input above didn't error initially is because malli reads it as an option-map

👍 1
👍🏽 1
Samuel Ludwig 2026-06-04T15:50:30.246139Z

so it was just "a vector, with some options that i don't know about atm so they just do nothing"

Shantanu Kumar 2026-06-04T15:52:02.752899Z

Right, that was treated option map - I couldn't spot that earlier.