This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-03
Channels
- # announcements (5)
- # babashka (8)
- # beginners (98)
- # biff (2)
- # calva (20)
- # cider (16)
- # clerk (2)
- # clj-kondo (20)
- # cljdoc (19)
- # clojure (90)
- # clojure-art (3)
- # clojure-boston (1)
- # clojure-europe (7)
- # clojure-nl (2)
- # clojure-norway (47)
- # clojure-uk (3)
- # clojurescript (10)
- # cursive (10)
- # data-science (1)
- # datalevin (1)
- # defnpodcast (1)
- # events (2)
- # fulcro (11)
- # gratitude (2)
- # honeysql (18)
- # hyperfiddle (11)
- # introduce-yourself (1)
- # jobs (2)
- # lambdaisland (4)
- # lsp (6)
- # malli (4)
- # membrane (3)
- # off-topic (58)
- # polylith (14)
- # portal (2)
- # releases (2)
- # ring-swagger (4)
- # tools-deps (8)
- # xtdb (8)
Hi I am trying to use malli to validate the input LocalDate string in params I did try to use malli.experimental.time but seems like it cannot handle the localDate string Ideally i used regex ealier but this breaks the Swagger doc as json is not able to convert regex. So if someone has some experiance with this that will be helpful
(def some-obj
[:map
[:rate [:maybe number?]]
[:myDate [:maybe [:re #"^\d{4}-\d{2}-\d{2}"]]]
[:myDate2 [:maybe [:re #"^\d{4}-\d{2}-\d{2}"]]]])
Want to validate localDate string like "2020-12-02"
Swagger Error
Caused by: com.fasterxml.jackson.core.JsonGenerationException: Cannot JSON encode object of class: class java.util.regex.Pattern: ^\d{4}-\d{2}-\d{2}
it needs decoder https://github.com/metosin/malli/blob/master/test/malli/experimental/time/transform_test.cljc#L13 but should work
in case you are using reitit there is a doc how to configure it https://cljdoc.org/d/metosin/reitit/0.7.0-alpha7/doc/coercion/malli#configuring-coercion
👀 1