Fork me on GitHub
#malli
<
2020-04-16
>
grounded_sage09:04:28

This bug https://github.com/metosin/malli/issues/196 is pretty critical for us atm. I’m happy to try jump in and fix if someone can point me in the right direction with some ideas on how to fix it.

ikitommi12:04:50

for empty sequences, it tries to figure out what is a valid schema and finds empty :or

ikitommi12:04:07

(require '[malli.provider])
(malli.provider/provide [[]])
; => [:vector [:or]]

ikitommi12:04:05

@grounded_sage should be fixed in master.

metal 8
ikitommi12:04:43

(provide [])
; => any?

(provide [[]])
; => [:vector any?]

(provide [[[[[[[]]]]]]])
; => [:vector [:vector [:vector [:vector [:vector [:vector any?]]]]]]

grounded_sage14:04:07

This is so helpful for the work I am doing atm where we are ingesting messy JSON from third parties. I use Malli to show me all the variations of schemas their JSON can have. Check the frequencies to see which ones we want to support. Can deep diff the schemas to see the differences. Then use the generated unified schema as the base for robust Meander pattern matching.

ikitommi16:04:29

Sounds cool! do you write the meander definitions manually or programmatically from schemas?

grounded_sage16:04:39

Create them manually. Would be interesting to see if I can generate a nice starting point from a Malli schema.. haven’t dove in that much yet to see if it’s practical.

grounded_sage16:04:32

Reminds me I did find another bug or unexpected behaviour earlier. Where doing unions over a number of schemas resulted in created some nested schema definitions that weren’t there. I got around this by just capturing the original JSON for the various schemas