Fork me on GitHub
#malli
<
2022-01-03
>
Swapneil19:01:41

How do you make a spec for a :repeat or :sequential with a certain length? I tried adding :count and :length in the properties, but neither seems to have an effect. My current spec is [:repeat {:min 0 :max 9} :int]]

ikitommi14:01:20

try:

(m/explain [:repeat {:min 2, :max 2} :int] [1 2])
; nil

(m/explain [:repeat {:min 2, :max 2} :int] [1])
;{:schema [:repeat {:min 2, :max 2} :int],
; :value [1],
; :errors ({:path [0]
;           :in [1]
;           :schema :int
;           :value nil
;           :type :malli.core/end-of-input})}

yes 1