Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#inst cannot be coerced to :time/instant #1163

Open
filipesilva opened this issue Jan 17, 2025 · 0 comments
Open

#inst cannot be coerced to :time/instant #1163

filipesilva opened this issue Jan 17, 2025 · 0 comments

Comments

@filipesilva
Copy link

Although a time string can be coerced, an actual instant of the same string cannot:

(ns user)

(comment
  (add-libs {'metosin/malli {:mvn/version "0.17.0"}})
  (require '[malli.core :as m]
           '[malli.registry :as mr]
           '[malli.experimental.time :as met]
           '[malli.experimental.time.transform :as mett])

  (mr/set-default-registry!
   (mr/composite-registry
     (m/default-schemas)
     (met/schemas)))

  (def t "2025-01-10T13:40:28.461494000-00:00")
  (m/coerce :time/instant t mett/time-transformer)
  ;; => #object[java.time.Instant 0x641c01c9 "2025-01-10T13:40:28.461494Z"]

  (def ti #inst "2025-01-10T13:40:28.461494000-00:00")
  (m/coerce :time/instant ti mett/time-transformer)
  ;; => Execution error (ExceptionInfo) at malli.core/-exception (core.cljc:157).
  ;;    :malli.core/coercion
  ,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant