Closed jpmonettas closed 8 years ago
Thanks for the report. either
is deprecated in Schema 1.x and does not work with recursive, try if
or conditional
instead, e.g.
(declare Sch1 Sch2)
(def Child
(s/if #(integer? (:v %)) (s/recursive #'Sch1) (s/recursive #'Sch2)))
(def Sch1
{:v s/Int
(s/optional-key :childs) [Child]})
(def Sch2
{:v s/Str
(s/optional-key :childs) [Child]})
(s/check Sch1 {:v 10
:childs [{:v "bar"
:childs [{:v 5} {:v "foo"}]}]})
Like a charm! Thanks a lot, and great library by the way!
No problem, thanks!
On Fri, Mar 11, 2016 at 2:10 AM, Juan Monetta notifications@github.com wrote:
Closed #347 https://github.com/plumatic/schema/issues/347.
— Reply to this email directly or view it on GitHub https://github.com/plumatic/schema/issues/347#event-585472217.
I'm trying to define a couple of mutually recursive schemas and getting a StackOverflowError when validating them. Maybe it's I'm not using it correctly.
This is a minimal example that doesn't work for me :
Working with schema 1.0.5 and clojure 1.8