This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-30
Channels
- # aleph (4)
- # announcements (5)
- # architecture (1)
- # aws (5)
- # babashka (12)
- # beginners (143)
- # chlorine-clover (4)
- # cider (16)
- # clj-kondo (44)
- # cljfx (26)
- # cljsrn (2)
- # clojure (34)
- # clojure-europe (28)
- # clojure-gamedev (1)
- # clojure-nl (3)
- # clojure-provo (2)
- # clojure-spec (6)
- # clojure-uk (17)
- # clojurescript (99)
- # code-reviews (6)
- # core-async (15)
- # cryogen (9)
- # cursive (14)
- # data-science (1)
- # datomic (16)
- # duct (1)
- # events (4)
- # exercism (1)
- # figwheel-main (3)
- # fulcro (3)
- # hugsql (7)
- # leiningen (4)
- # malli (15)
- # off-topic (13)
- # pathom (8)
- # re-frame (7)
- # reitit (35)
- # remote-jobs (1)
- # sci (10)
- # shadow-cljs (32)
- # sql (5)
- # tools-deps (102)
- # tree-sitter (3)
- # uncomplicate (7)
- # vim (40)
- # xtdb (8)
Hi! I’m using Malli schemas to generate a Swagger spec using Reitit (ie. “issue_date”). These schemas have encoding fns so “issue_date” is coerced to :document/issue-date so it can be saved into Datomic. I want to confirm if the Reitit coercers do validation after coercion right? Because I’m not getting it to validate as “issue_date” but :document/issue-date
It is what I can see from the code and from the behaviour. If I want to keep the json-like schemas for Swagger generation AND validate using those, I need to do coercion after all that manually right?
@lmergen @rschmukler should there be m/assert
?
i think there should be -- i have two functions myself actually, assert
and have
, where have
is inspired by ptaoussanis' truss -- https://github.com/ptaoussanis/truss
effectively, have
does the assertion + also returns the input value if no failure was detected. this allows for a pattern such as
(let [foo (m/have foo-schema (get x :foo))]
...)
it's very effective.
i would be happy to send a PR for the assert
and/or have
implementations i have right now (which seem to be doing the right thing)the m/defn
, currently have a separate malli.schema
ns, and few helper ns's under it. Will have the 1:1 Plumatic Schema m/defn
for Malli. Once done, will do the real full malli->clj-kondo integration, that can be used with both malli-defn and aave, and a standard fdef
-kinda way to annotate existing functions like in spec.
might be worth trying to write spec->malli conversion, so we could reuse all the existing fdef
s out there. Also, zillion little things to do :)
@ikitommi once we have that I may take a crack at some nrepl middleware and cider integration. Right now you can spec generate and see spec definitions in documentation lookup in emacs. Only thing I miss from spec.
Re: m/assert
- why not? I think it'll be attractive for some of those migrating from spec