Fork me on GitHub
#malli
<
2024-02-07
>
bzmariano21:02:32

Hello, today I was using Malli and I tried to validate a UUID using (malli.core/validate :uuid "caa71a26-5fe1-11ec-bf63-0242ac130002"). However, it returned false. The string is from an example on the Malli GitHub page (under the title "decoding schema in inferring") , and I've also tried a couple of other valid UUID strings and using uuid? instead of the keyword. Does anybody have an idea what the problem could be?

Stig Brautaset21:02:56

it's not a UUID, it's a string representation of a UUID.

Stig Brautaset21:02:13

Try (malli.core/validate :uuid #uuid "caa71a26-5fe1-11ec-bf63-0242ac130002")

Stig Brautaset21:02:49

it fails for the same reason that "1" is not an integer, it's a string representation of an integer.

bzmariano22:02:14

Right, the same happened to me with java dates types and I just forgot about that 😅 #uuid works great. Thanks for the help!

bzmariano22:02:36

if I have [:map [:id :uuid] [:age :int]], Is it possible to insert the #uuid in the map schema ?

Stig Brautaset22:02:22

You can see there that {:id #uuid "46286bb1-3734-402f-8d8f-36f816d63367", :age 0} conforms to the map schema you gave

bzmariano22:02:14

Cool, didn't know about malli playground. Thanks.