Fork me on GitHub

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?


Or of course write my own Malli coercer that always decodes.


I would appreciate any pointers on this


@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 -- 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)


@eraad coercion is decode + validate in reitit-malli


for responses, I recall it's validate + encode


have had a super busy two weeks, should have few full days of malli after next wed.


Thanks @ikitommi got you


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.

👍 3

might be worth trying to write spec->malli conversion, so we could reuse all the existing fdefs 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