Fork me on GitHub
#malli
<
2020-07-18
>
ikitommi07:07:44

big change is that collection transformers don't coerce their type if children don't need transformation. In practise:

(m/decode [:vector keyword?] '("abba") (mt/json-transformer))
; => [:abba]

(m/decode [:vector string?] '("abba") (mt/json-transformer))
; => ("abba")

ikitommi07:07:48

for string-transformer, works like before:

(m/decode [:vector string?] '("abba") (mt/string-transformer))
; => [:abba]

ikitommi07:07:16

=> the transformer instances can decide how to transform the collections, with JSON, both Jsonista and Cheshire decode JSON arrays as vectors, so they don’t need any “just in case” transformations.

ikitommi07:07:19

if you have a deep Malli Schema, which only has things that can be presented in JSON, the transformation engine return identity. Which is nice.