Fork me on GitHub
#malli
<
2021-08-15
>
Asko Nōmm19:08:50

Hi! I found a interesting issue in CLJS where Malli fails with "Invalid schema" when checking for object? , for example:

(m/validate [:or map? object?] input)
Fails. However whenever I remove the object?, it starts working. How do I validate a JS object with Malli if object? makes Malli fail?

emccue20:08:50

only certain predicates are "built in" - i.e. have an implicit mapping to something. map? gets swapped with [:map], effectively

emccue20:08:42

if you want to use a custom predicate you can either use [:fn object?] - which won't have generation semantics if you use that for your project

emccue20:08:00

there is also a way to make a custom schema key/generator/etc. I just don't know it offhand

emccue20:08:25

it is documented here though

Asko Nōmm20:08:17

Cheers @U3JH98J4R, this solved it perfectly. I didn't know that it swapped the predicates, this makes sense now!