diff --git a/README.md b/README.md index ce10196..8799f49 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Lilac: some validation functions in ClojureScript [![Clojars Project](https://img.shields.io/clojars/v/mvc-works/lilac.svg)](https://clojars.org/mvc-works/lilac) ```edn -[mvc-works/lilac "0.1.1-a1"] +[mvc-works/lilac "0.1.1-a2"] ``` ```clojure diff --git a/calcit.cirru b/calcit.cirru index 29eb6ea..0fc6308 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -1732,15 +1732,111 @@ |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |empty?) (:id |1Bg0BC-Ar) |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |xs) (:id |RXWbCAN6t) :id |hTJDUJQ8T - |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476387448) + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562136662) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |{}) (:id |FRWI0oIJc) - |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476387448) + |T $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476387448) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |{}) (:id |FRWI0oIJc) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476387448) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |:ok?) (:id |wceCom3nyp) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |true) (:id |HvbgE8ITlE) + :id |0ImWpykc5 + :id |_HeImmokn + |D $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562156076) (:text |if) (:id |BVGGsM9F) + |L $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562156737) (:text |check-size?) (:id |XRMmNLEKN) + |P $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562157792) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |:ok?) (:id |wceCom3nyp) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |true) (:id |HvbgE8ITlE) - :id |0ImWpykc5 - :id |_HeImmokn + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562160238) (:text |if) (:id |vLFVCySb) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562662268) + :data $ {} + |T $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562161182) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562162611) (:text |empty?) (:id |ynIb30pIu) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562164606) (:text |ys) (:id |KWgyjPwJ) + :id |KhXYro7C + |D $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562663018) (:text |and) (:id |8bMvRnmPa) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562664772) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562665281) (:text |=) (:id |if4RZgfa) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562665807) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562669593) (:text |count) (:id |2CObr3TLU) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562671653) (:text |items) (:id |VHy_5iXF6) + :id |v7slAs515 + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562672503) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562674208) (:text |count) (:id |0bipm7qm) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562674800) (:text |data) (:id |xj2_kn352) + :id |W5tl4c4vn + :id |QaD2Jgh6c + :id |q1cLG5iE + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562178651) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562178651) (:text |{}) (:id |-I83ZmQpy) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562178651) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562178651) (:text |:ok?) (:id |pu4RKGqdH) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562178651) (:text |true) (:id |T3MwR5Vgw) + :id |kMLGIWoJb + :id |NALAxvdMM + |v $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562191506) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |{}) (:id |QIPAES-ZJ) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562191506) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |:ok?) (:id |Gla8fNdN8) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |false) (:id |RSYgNGRLs) + :id |wXlZ3penl + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562191506) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |:coord) (:id |MJa67gMDo) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |next-coord) (:id |vt4odRMBh) + :id |1bLvtnnv2 + |v $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562191506) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |:rule) (:id |3JguEwiix) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |rule) (:id |C3YGOHeZa) + :id |le_eaLYA- + |x $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562191506) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |:data) (:id |sPF0K9jyq) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562233641) (:text |ys) (:id |sHwyhconk) + :id |MMUpDXpmc + |y $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562191506) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |:message) (:id |9BSeK-wRNA) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562191506) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |get-in) (:id |pd5mydip1o) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |rule) (:id |dxhvcuyr-H) + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562191506) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |[]) (:id |H5_Cdrh34X) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |:options) (:id |OP2HzDJJx7) + |r $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562191506) (:text |:message) (:id |M_z-duHQL9) + :id |pxkHWs4vXn + |v $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562261205) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562694758) (:text "|\"expects tuple of ") (:id |3HyeS1h-gM) + |D $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562262012) (:text |str) (:id |q3chnrojf) + |b $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562695486) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562696904) (:text |count) (:id |oiUAaSDiD) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562697528) (:text |items) (:id |QBPvktbzQ) + :id |HK-beIa4 + |f $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562702743) (:text "|\" items, got ") (:id |1YDZkx3B) + |h $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562703873) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562704992) (:text |count) (:id |SwFsSnEz) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562706025) (:text |data) (:id |xcJufFIq) + :id |RGEsp3YMk + :id |iJK_ZBDu + :id |lIZs9iUmZS + :id |4qbPReZHxw + :id |XNY6Kyxkz + :id |r8N1kSQ_C + :id |ja991cksQ |v $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476387448) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476387448) (:text |let) (:id |F6ZsegEslp) @@ -1866,6 +1962,15 @@ |L $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476389494) (:data $ {}) (:id |P4uOidDaA) :id |VTJ3hgDx :id |voMHnqF3E + |t $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562142728) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562144973) (:text |check-size?) (:id |5Al-EFYkleaf) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562145293) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562149954) (:text |:check-size?) (:id |b3Upd1uv) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562148763) (:text |rule) (:id |WtAqBRJ79) + :id |TFdxERW13 + :id |5Al-EFYk :id |5EI7dbV3f |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476337414) :data $ {} @@ -3536,6 +3641,15 @@ |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476289945) (:text |options) (:id |SeR_81Ei) :id |4HElg3h_ :id |8YuiFH_T + |y $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562364785) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562367574) (:text |:check-size?) (:id |a8ze9wzRzleaf) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562367877) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562373715) (:text |:check-size?) (:id |1HOiOKIBL) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562371602) (:text |options) (:id |UuczAYa0n) + :id |udPLXS5Mu + :id |a8ze9wzRz :id |yqQzkXov3f :id |_V9-ajQk4 :id |6QNIOwvum @@ -5253,7 +5367,7 @@ |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1579852538047) (:text |:else) (:id |Wkb6iPm3leaf) |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1579854979081) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1579854996397) (:text "|\"Unknown(") (:id |hKS22zFd) + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562455882) (:text "|\"Unknown: ") (:id |hKS22zFd) |D $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1579854980445) (:text |str) (:id |u3LUYDDd4) |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1579854998018) :data $ {} @@ -5266,7 +5380,6 @@ |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1579855001019) (:text |0) (:id |34nzqOJi) |r $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1579855001951) (:text |10) (:id |__DIdxLX) :id |PwtEsjCtt - |r $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1579854991099) (:text "|\")") (:id |l82548yk) :id |vtg8jmJj :id |Wkb6iPm3 |yT $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1579852494426) @@ -5353,6 +5466,15 @@ :id |ehXj_-8- |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1579852493219) (:text "|\"a vector") (:id |F_ZDEALd5) :id |qofK5cf- + |yn $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562556773) + :data $ {} + |T $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562557441) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562559574) (:text |seq?) (:id |TM9vqymN1leaf) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562579342) (:text |x) (:id |q_sbfm8r) + :id |IYvcuMIR + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562586306) (:text "|\"a seq") (:id |WmhDpGZ32) + :id |TM9vqymN1 |wT $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1579852527307) :data $ {} |T $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1579852527307) @@ -6223,18 +6345,17 @@ |test-tuple $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476825988) (:text |deftest) (:id |_IjsUql8A) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476819616) (:text |test-tuple) (:id |zKfJhznYo) - |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) + |w $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476833117) (:text |testing) (:id |Y4_AsF2KU) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476855030) (:text "|\"an empty tuple") (:id |fwcjiP8E) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476915377) (:text "|\"an empty tuple in list") (:id |fwcjiP8E) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476836472) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476836734) (:text |is) (:id |vuHRn9M1) |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476840114) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476841171) (:text |=ok) (:id |OFZhFphyR) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476842305) (:text |true) (:id |7gVjgOVG4) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477195241) (:text |true) (:id |7gVjgOVG4) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476848436) (:text |validate-lilac) (:id |CVvZABuy3) @@ -6245,26 +6366,35 @@ :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476868954) (:text |[]) (:id |aTpKII-R5) :id |rHBcrtsZu + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477203565) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477203980) (:text |{}) (:id |Ft99BrwD) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477204339) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477206984) (:text |:in-list?) (:id |fo5uZPw_) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477207592) (:text |true) (:id |BbxGzKjg) + :id |S4UX84PM4 + :id |jofzD0UuT :id |VvJPvFPf- |f $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476863219) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476863556) (:text |[]) (:id |pbdj5zo85) + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477098022) (:text |list) (:id |pbdj5zo85) :id |OMIL6LIF :id |GZ-HfjkoQ :id |gRWVlK7l :id |NvmIWR96t - :id |eWg25i81t - |v $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) + :id |4xWgORMUT + |yr $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476833117) (:text |testing) (:id |Y4_AsF2KU) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477199289) (:text "|\"check an empty tuple in list") (:id |fwcjiP8E) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477282430) (:text "|\"tuple not right type") (:id |fwcjiP8E) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476836472) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476836734) (:text |is) (:id |vuHRn9M1) |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476840114) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476841171) (:text |=ok) (:id |OFZhFphyR) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477107994) (:text |false) (:id |7gVjgOVG4) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562324616) (:text |true) (:id |7gVjgOVG4) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476848436) (:text |validate-lilac) (:id |CVvZABuy3) @@ -6274,27 +6404,42 @@ |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476868665) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476868954) (:text |[]) (:id |aTpKII-R5) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477147849) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477151299) (:text |number+) (:id |gHxy8FLQ7) + :id |fw2mPzbN :id |rHBcrtsZu + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562310917) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562311372) (:text |{}) (:id |h83mJvRZ-leaf) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562311697) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562359437) (:text |:check-size?) (:id |8bTyOcAEK) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562750380) (:text |false) (:id |aUUMLPMU3) + :id |nQtmkfQKw + :id |h83mJvRZ- :id |VvJPvFPf- |f $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476863219) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477098022) (:text |list) (:id |pbdj5zo85) + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477262496) (:text |[]) (:id |pbdj5zo85) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477142910) (:text |1) (:id |1VFymCTt) + |x $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562736846) (:text "|\"1") (:id |-uXnOUTi5) :id |OMIL6LIF :id |GZ-HfjkoQ :id |gRWVlK7l :id |NvmIWR96t - :id |SHZeJn3zX - |x $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) + :id |lg8wlexi + |yT $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476833117) (:text |testing) (:id |Y4_AsF2KU) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477136798) (:text "|\"tuple of number string boolean") (:id |fwcjiP8E) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477282430) (:text "|\"tuple not right type") (:id |fwcjiP8E) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476836472) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476836734) (:text |is) (:id |vuHRn9M1) |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476840114) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476841171) (:text |=ok) (:id |OFZhFphyR) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477139220) (:text |true) (:id |7gVjgOVG4) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581478027011) (:text |false) (:id |7gVjgOVG4) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476848436) (:text |validate-lilac) (:id |CVvZABuy3) @@ -6310,7 +6455,7 @@ :id |fw2mPzbN |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477151781) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477154354) (:text |string+) (:id |kDcWmOrGKleaf) + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477257315) (:text |number+) (:id |kDcWmOrGKleaf) :id |kDcWmOrGK |v $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477158445) :data $ {} @@ -6320,7 +6465,7 @@ :id |VvJPvFPf- |f $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476863219) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477141918) (:text |[]) (:id |pbdj5zo85) + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477262496) (:text |[]) (:id |pbdj5zo85) |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477142910) (:text |1) (:id |1VFymCTt) |r $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477143727) (:text "|\"1") (:id |j1tqEN8B) |v $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477145243) (:text |true) (:id |tlUjWjsIZ) @@ -6328,18 +6473,19 @@ :id |GZ-HfjkoQ :id |gRWVlK7l :id |NvmIWR96t - :id |8KC4-kYK - |y $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) + :id |2rc8AaBJa + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476819616) (:text |test-tuple) (:id |zKfJhznYo) + |x $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476833117) (:text |testing) (:id |Y4_AsF2KU) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477184550) (:text "|\"tuple not vector") (:id |fwcjiP8E) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477136798) (:text "|\"tuple of number string boolean") (:id |fwcjiP8E) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476836472) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476836734) (:text |is) (:id |vuHRn9M1) |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476840114) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476841171) (:text |=ok) (:id |OFZhFphyR) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477247070) (:text |false) (:id |7gVjgOVG4) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477139220) (:text |true) (:id |7gVjgOVG4) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476848436) (:text |validate-lilac) (:id |CVvZABuy3) @@ -6365,7 +6511,7 @@ :id |VvJPvFPf- |f $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476863219) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477238275) (:text |list) (:id |pbdj5zo85) + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477141918) (:text |[]) (:id |pbdj5zo85) |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477142910) (:text |1) (:id |1VFymCTt) |r $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477143727) (:text "|\"1") (:id |j1tqEN8B) |v $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477145243) (:text |true) (:id |tlUjWjsIZ) @@ -6373,18 +6519,18 @@ :id |GZ-HfjkoQ :id |gRWVlK7l :id |NvmIWR96t - :id |Qo_LDl-MP - |w $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) + :id |8KC4-kYK + |v $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476833117) (:text |testing) (:id |Y4_AsF2KU) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476915377) (:text "|\"an empty tuple in list") (:id |fwcjiP8E) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477199289) (:text "|\"check an empty tuple in list") (:id |fwcjiP8E) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476836472) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476836734) (:text |is) (:id |vuHRn9M1) |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476840114) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476841171) (:text |=ok) (:id |OFZhFphyR) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477195241) (:text |true) (:id |7gVjgOVG4) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477107994) (:text |false) (:id |7gVjgOVG4) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476848436) (:text |validate-lilac) (:id |CVvZABuy3) @@ -6395,15 +6541,6 @@ :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476868954) (:text |[]) (:id |aTpKII-R5) :id |rHBcrtsZu - |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477203565) - :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477203980) (:text |{}) (:id |Ft99BrwD) - |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477204339) - :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477206984) (:text |:in-list?) (:id |fo5uZPw_) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477207592) (:text |true) (:id |BbxGzKjg) - :id |S4UX84PM4 - :id |jofzD0UuT :id |VvJPvFPf- |f $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476863219) :data $ {} @@ -6412,8 +6549,8 @@ :id |GZ-HfjkoQ :id |gRWVlK7l :id |NvmIWR96t - :id |4xWgORMUT - |yT $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) + :id |SHZeJn3zX + |yj $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476833117) (:text |testing) (:id |Y4_AsF2KU) |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477282430) (:text "|\"tuple not right type") (:id |fwcjiP8E) @@ -6423,7 +6560,82 @@ |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476840114) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476841171) (:text |=ok) (:id |OFZhFphyR) - |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581478027011) (:text |false) (:id |7gVjgOVG4) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562758893) (:text |false) (:id |7gVjgOVG4) + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476848436) (:text |validate-lilac) (:id |CVvZABuy3) + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476865763) (:text |tuple+) (:id |GZZq3wHSe) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476868665) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476868954) (:text |[]) (:id |aTpKII-R5) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477147849) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477151299) (:text |number+) (:id |gHxy8FLQ7) + :id |fw2mPzbN + :id |rHBcrtsZu + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562310917) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562311372) (:text |{}) (:id |h83mJvRZ-leaf) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581562311697) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562359437) (:text |:check-size?) (:id |8bTyOcAEK) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562316449) (:text |true) (:id |aUUMLPMU3) + :id |nQtmkfQKw + :id |h83mJvRZ- + :id |VvJPvFPf- + |f $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476863219) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477262496) (:text |[]) (:id |pbdj5zo85) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477142910) (:text |1) (:id |1VFymCTt) + |x $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581562736846) (:text "|\"1") (:id |-uXnOUTi5) + :id |OMIL6LIF + :id |GZ-HfjkoQ + :id |gRWVlK7l + :id |NvmIWR96t + :id |7HVkNZ6b + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476833117) (:text |testing) (:id |Y4_AsF2KU) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476855030) (:text "|\"an empty tuple") (:id |fwcjiP8E) + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476836472) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476836734) (:text |is) (:id |vuHRn9M1) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476840114) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476841171) (:text |=ok) (:id |OFZhFphyR) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476842305) (:text |true) (:id |7gVjgOVG4) + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476848436) (:text |validate-lilac) (:id |CVvZABuy3) + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476865763) (:text |tuple+) (:id |GZZq3wHSe) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476868665) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476868954) (:text |[]) (:id |aTpKII-R5) + :id |rHBcrtsZu + :id |VvJPvFPf- + |f $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476863219) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476863556) (:text |[]) (:id |pbdj5zo85) + :id |OMIL6LIF + :id |GZ-HfjkoQ + :id |gRWVlK7l + :id |NvmIWR96t + :id |eWg25i81t + |y $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476819616) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476833117) (:text |testing) (:id |Y4_AsF2KU) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477184550) (:text "|\"tuple not vector") (:id |fwcjiP8E) + |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476836472) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476836734) (:text |is) (:id |vuHRn9M1) + |j $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476840114) + :data $ {} + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476841171) (:text |=ok) (:id |OFZhFphyR) + |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477247070) (:text |false) (:id |7gVjgOVG4) |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476848436) :data $ {} |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581476848436) (:text |validate-lilac) (:id |CVvZABuy3) @@ -6439,7 +6651,7 @@ :id |fw2mPzbN |r $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477151781) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477257315) (:text |number+) (:id |kDcWmOrGKleaf) + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477154354) (:text |string+) (:id |kDcWmOrGKleaf) :id |kDcWmOrGK |v $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581477158445) :data $ {} @@ -6449,7 +6661,7 @@ :id |VvJPvFPf- |f $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1581476863219) :data $ {} - |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477262496) (:text |[]) (:id |pbdj5zo85) + |T $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477238275) (:text |list) (:id |pbdj5zo85) |j $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477142910) (:text |1) (:id |1VFymCTt) |r $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477143727) (:text "|\"1") (:id |j1tqEN8B) |v $ {} (:type :leaf) (:by |yeKFqj7rX) (:at 1581477145243) (:text |true) (:id |tlUjWjsIZ) @@ -6457,7 +6669,7 @@ :id |GZ-HfjkoQ :id |gRWVlK7l :id |NvmIWR96t - :id |2rc8AaBJa + :id |Qo_LDl-MP :id |_5X9NrXMC |test-vector $ {} (:type :expr) (:by |yeKFqj7rX) (:at 1579602380741) :data $ {} diff --git a/pom.xml b/pom.xml index 9dc8e79..e79e3dc 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mvc-works lilac - 0.1.1-a1 + 0.1.1-a2 lilac https://github.com/mvc-works/lilac diff --git a/src/lilac/core.cljs b/src/lilac/core.cljs index 95930b7..be705ff 100644 --- a/src/lilac/core.cljs +++ b/src/lilac/core.cljs @@ -227,10 +227,26 @@ (let [items (:items rule) next-coord (conj coord 'tuple) in-list? (:in-list? rule) + check-size? (:check-size? rule) check-values (fn [] (loop [xs items, ys data, idx 0] (if (empty? xs) - {:ok? true} + (if check-size? + (if (and (empty? ys) (= (count items) (count data))) + {:ok? true} + {:ok? false, + :coord next-coord, + :rule rule, + :data ys, + :message (get-in + rule + [:options :message] + (str + "expects tuple of " + (count items) + " items, got " + (count data)))}) + {:ok? true}) (let [r0 (first xs) y0 (first ys) child-coord (conj next-coord idx) @@ -531,7 +547,11 @@ ([items] (tuple+ items nil)) ([items options] (assert (vector? items) "expects items of tuple+ in vector") - {:lilac-type :tuple, :items items, :options options, :in-list? (:in-list? options)})) + {:lilac-type :tuple, + :items items, + :options options, + :in-list? (:in-list? options), + :check-size? (:check-size? options)})) (defn vector+ ([item] (vector+ item nil)) diff --git a/src/lilac/test.cljs b/src/lilac/test.cljs index efadc8d..4fddc72 100644 --- a/src/lilac/test.cljs +++ b/src/lilac/test.cljs @@ -270,7 +270,13 @@ (=ok false (validate-lilac (list 1 "1" true) (tuple+ [(number+) (string+) (boolean+)]))))) (testing "tuple not right type" - (is (=ok false (validate-lilac [1 "1" true] (tuple+ [(number+) (number+) (boolean+)])))))) + (is (=ok false (validate-lilac [1 "1" true] (tuple+ [(number+) (number+) (boolean+)]))))) + (testing + "tuple not right type" + (is (=ok false (validate-lilac [1 "1"] (tuple+ [(number+)] {:check-size? true}))))) + (testing + "tuple not right type" + (is (=ok true (validate-lilac [1 "1"] (tuple+ [(number+)] {:check-size? false})))))) (deftest test-vector diff --git a/src/lilac/util.cljs b/src/lilac/util.cljs index 831dfa4..5b9c139 100644 --- a/src/lilac/util.cljs +++ b/src/lilac/util.cljs @@ -13,7 +13,8 @@ (set? x) "a set" (list? x) "a list" (nil? x) "nil" - :else (str "Unknown(" (subs (str x) 0 10) ")"))) + (seq? x) "a seq" + :else (str "Unknown: " (subs (str x) 0 10)))) (def type-of-re (type #"x"))