Fork me on GitHub
#malli
<
2023-10-28
>
Ramon Rios11:10:39

Folks, Can I, based in one value, define what should be the schema for other property? Example:

{:key1 2
:other-key ""}

{:key1 3
:other-key "should not be empty"}

[:map 
 [:key1 number?]
[:other-key (if (= 2 :key1 )
empty?
other-validation)]]

ikitommi17:10:16

Maybe :multi ?

[:multi {:dispatch :key1}
 [2 [:map [:other-key :string]]]
 [3 [:map [:other-key :int]]]]

ray11:10:14

wondering if anyone has a port of https://github.com/clojure/core.specs.alpha for #malli? Asking for a friend 😇

👀 1
hifumi12318:10:44

even if there were, it wouldn't be useful since the clojure compiler only let's clojure.spec validate macros

ray08:10:54

It can still be useful for linters, analysers and editors.