plumatic / schema

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

validate slow when there's an error #352

Closed sonwh98 closed 8 years ago

sonwh98 commented 8 years ago
(def KoalaState {:company-name s/Str
                           :logged-in s/Bool})

(s/validate KoalaState {:company-name "koala" :logged-in "false"})

validate returns immediately when the type matches. However, if it doesn't match like the above, it takes a 20 seconds to return the error message. Is this normal?

validate returns quickly when there's an error in Clojure. The slowness is only in ClojureScript

w01fe commented 8 years ago

First I've heard about this. My guess is it's something to do with your environment and how it handles errors, rather than anything to do with schema. What happens if you just throw an exception rather than calling s/validate?

sonwh98 commented 8 years ago

oh you're right. I was testing it in the boot.cljs clojurescript repl. (js/throw "foo") also takes a long time