Fork me on GitHub
#malli
<
2022-07-13
>
George Peristerakis14:07:18

I have a registry with large data objects specs. I created a list of base specs to have a more consistent taxonomy ex: :pk-int [int? {:min 1 :unique true}] . What is the best way to represent these base specs? Should I have a separate registry or keep them in the same registry?

DrLjótsson16:07:07

Newbie question: How do I specify that a value should be of a specific class, for example java.time.ZonedDateTime

respatialized16:07:29

[:fn #(instance? % java.time.ZonedDateTime)]

respatialized16:07:23

Not sure if there's another "official" way but I've done it that way in the past

DrLjótsson16:07:07

Thanks! I thought there might be a more official way but this will do just fine.

Bart Kleijngeld13:02:29

It might be handy to create a new schema type for such Java classes. Here's an example by Tommi for Long:

(def a-long (m/-simple-schema {:pred #(instance? Long %)}))

(m/validate a-long (Integer. 12)) ;=> false
(m/validate a-long (Long. 12)) ; => true

Tiago Dall'Oca19:07:40

Hey, more of a implementation question: why schemas instances are implemented with reify instead of using records? When I tried extending IPrintWithWriter to malli.core.Schema it didn't work because the type generated for schemas with reify isn't malli.core.Schemas