Fork me on GitHub
#biff
<
2024-02-17
>
jamesmintram09:02:52

Hey all. I've been looking through a few Biff code bases and notice that wherever a date is required, it's schema defines it as: 'inst?' - why not something more specific which validates that is actually a date and not something else?

Jacob O'Bryant20:02:11

Is your point that inst? returns true for both objects of type java.util.Date and java.time.Instant, and perhaps it'd be better to check explicitly for one or the other? If so, that seems reasonable--using inst? isn't something I've put much thought into. I see malli has some https://github.com/metosin/malli?tab=readme-ov-file#malliexperimentaltime for java.time types; I'd be open to switching the starter and tutorial apps over to those.

Safe Hammad08:02:19

Hey @U074GLVT6! I'm using the malli date and time schemas such as :time/local-date in biff's schema.clj file with just a couple of lines added to the "main" namespace:

(ns com.example
  (:require ...
            [malli.experimental.time :as met]
            ...))

...

(def malli-opts
  {:registry (malr/composite-registry
              malc/default-registry
              (met/schemas)  ;  Enable malli experimental time schemas 
              (apply biff/safe-merge (keep :schema modules)))})

🙌 2