plumatic / schema

Clojure(Script) library for declarative data description and validation
Other
2.41k stars 257 forks source link

schema.core.EnumSchema - coercion of values doesn't work #271

Closed ikitommi closed 9 years ago

ikitommi commented 9 years ago

I guess the last one should work?

➜  ~  lein try prismatic/schema
nREPL server started on port 61622 on host 127.0.0.1 - nrepl://127.0.0.1:61622
REPL-y 0.3.7, nREPL 0.2.10
Clojure 1.7.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_31-b13
tommi's repl.
user=> (require '[schema.core :as s])
nil
user=> (require '[schema.coerce :as sc])
nil
user=> ((sc/coercer s/Int sc/string-coercion-matcher) "1")
1
user=> ((sc/coercer (s/enum 1 2) sc/string-coercion-matcher) "1")
#schema.utils.ErrorContainer{:error (not (#{1 2} "1"))}
ikitommi commented 9 years ago

fixed typo in the example, sc/+string-coercions+ => sc/string-coercion-matcher.

ikitommi commented 9 years ago

coerced keywords is enums do work, so don't need this. Closing it.