Fork me on GitHub
#malli
<
2019-11-04
>
ikitommi12:11:53

@roklenarcic in latest master, you can use IntoSchema values as element in the schema ast:

(require '[malli.core :as m])

(def sequential (#'m/-collection-schema `sequential sequential? seq nil))

(m/validate [sequential int?] '(1 2 3)) 
; => true

(m/validate [sequential int?] [1 2 3]) 
; => true

(m/form [sequential int?])
; => [user/sequential int?]

roklenarcic14:11:48

nice trick to get around private var 🙂

ikitommi17:11:28

not complete, transforming needs to retain the original type, but an example of all the extensions implemented and tested for a schema: https://github.com/metosin/malli/pull/110

ikitommi17:11:56

I'm thinking of adding a supporting protocol for the different extension, so one could just implement all the concerns with one reify.

ikitommi17:11:19

malli.json-schema/JsonSchema etc.

ikitommi17:11:15

not going to use the protocols in the core, e.g. core doesn't depend on anything to keep it small, but for custom new client schemas, I think the all-protocols approach is more declarative than the mixture of protocols and mms