Fork me on GitHub
#malli
<
2021-05-28
>
Pragyan Tripathi07:05:10

Is there a way I can use malli to generate datomic schema?

eoliphant20:05:06

not ‘out of the box’ per se but it’s pretty straight forward. depends on the way you define your schemas. We use the dynamic registry sort of like spec, so our attributes are first class which sort naturally maps to datomic, and then just map over the registry for our attrs, :{db/ident <attr> :db/valueType (malli-to-datomic …) …} theres of course specific stuff you’ll probably do for enums :my/enum [:enum :a :b] becomes norms for a :my/enum ref and :my.enum/a, etc. :map’s to refs, etc. We have our own custom options for additional customization when we generate.

👍 3
eoliphant20:05:01

also, this video talks about this in general in terms of using malli to drive a lot of the rest of your app. https://www.youtube.com/watch?v=ww9yR_rbgQs&amp;t=696s

eoliphant21:05:08

is there a way to muck with option values based on a predicate? in pseudo-malli…

[:map 
  [:a :boolean]
  [:b {:optional #(true? :a)} :boolean]]