metosin/malli

Sequence/regex schemas

ikitommi opened this issue · 4 comments

From slack:

like clojure.spec.alpha/conform, there could be something for that? Explain could return either failures or real values if no errors exist.

 (->
   [:cat
    [:x int?]
    [:y int?]
    [:rest [:* string?]]]
   [1 2 "kikka" "kukka"]
  (m/explain)
  (mu/humanize))
 ; {:x 1
 ;  :y 2
 ;  :rest ("kikka "kukka")}

and/or, an anonymous variant:

 (m/valid?
   [:cat int? int? [:* string?]]
   [1 2 "kikka" "kukka"])
 ; => true

using for example https://github.com/cgrand/seqexp under the hoods

When designing it, the scenario of implementing the equivalent of clojure.alpha.spec/unform might also be considered.

For info, I would use both conform and unform if malli has it.

Initial internal impl done, just 123loc. need to add tests and figure out how to expose the parsing api in general.

Screenshot 2020-09-10 at 20 41 31

Master!