malli icon indicating copy to clipboard operation
malli copied to clipboard

nested :repeat sequence schema's doesn't seem to work

Open ebunders opened this issue 2 years ago • 3 comments

using 0.8.9, if I evaluate (m/validate [:repeat [:repeat :int]] [[1 2 3] [4 5]]) I'm getting

Execution error (OutOfMemoryError) at malli.impl.regex/repeat-validator$optionals (regex.cljc:348).
Java heap space

Maybe this is not the right way to create a schema for multi-dimensional seqs, but that is not obvious, and there is nothing about it in the docs...

ebunders avatar Oct 09 '22 09:10 ebunders

This little experiment does not work either

(m/validate [:schema {:registry {"line" [:repeat :int]}} [:repeat "line"]] [[1 2] [3 4]])

ebunders avatar Oct 09 '22 12:10 ebunders

I'm marking this a bug and leaving open, should not blow up.

For your case, multi-dimensional seq can be presented either using normal :sequential (best fit for homogenous sequences) or with sequential schemas:

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

(m/validate [:repeat [:schema [:repeat :int]]] [[1 2 3] [4 5]])
; => true

ikitommi avatar Oct 16 '22 12:10 ikitommi

Ok thanks for the tips

ebunders avatar Oct 17 '22 06:10 ebunders