Fork me on GitHub
#reitit
<
2019-07-30
>
jmv20:07:14

i am trying to set up a spec decoder for reitit but it is not working as expected. should the result of the st/decode call be true instead of yes?

user> (defn ->bool [_ x]
        (if (string? x)
          (cond
            (= "yes" x) true
            (= "no"  x) false
            :else x)
          x))
;; => #'user/->bool
user> (s/def ::bool (st/spec #{"yes" "no"} {:decode/string ->bool}))
;; => :user/bool
user> (st/decode ::bool "yes")
;; => "yes"