metosin / schema-tools

Clojure(Script) tools for Plumatic Schema
http://metosin.github.io/schema-tools/
Eclipse Public License 2.0
107 stars 16 forks source link

select-schema #12

Closed ikitommi closed 9 years ago

ikitommi commented 9 years ago

Current select-schema can't handle keys predicates and fails silently when the value can't be coerced fully to match the schema.

In this PR, the internals are rewritten based on the discussion with the Prismatic guys. In addition, if a coercion fails, validation exception is thrown (identical to exception from schema.core/validate).

breaking change: select-schema now either a) succeeds and returns the coerced value or b) fails with an exception.

breaking change: argument order is changed to be coherent to other apis (supporting single-threading). Descriptive ex-info is thrown is fn is used with old argument order.

cichli commented 9 years ago

Found time to upgrade our codebase to 0.5.1 this morning - everything working fine so far, except there's a warning in CLJS now: WARNING: Use of undeclared Var schema-tools.core/Exception at line 192 target/cljs/schema_tools/core.cljs

Looks like the Exception on this line should be something like #+clj Exception #+cljs js/Error?

Thanks again for the work on this!

ikitommi commented 9 years ago

thanks! and fixed now in 0.5.2.