Hi,
I working with some legacy code and trying to eliminate schema/both type schemas and move towards "composable" schema/contrained based schemas.
Most of the schemas are decorated with s/named to provide friendly error messages for distinct error cases.
Consider the following toy example:
(defn positive [x] (s/named (s/constrained x pos?) "The amount should be positive"))
(defn less-than [x m] (s/named (s/constrained x #(> m %)) (str "The amount should be less than " m)))
(def some-param-schema (-> s/Int (positive) (less-than 10)))
Now the following call:
(schema/check some-param-schema -1)
returns:
(named (named (not (pos? -1)) "The amount should be positive") "The amount should be less than 10")
This is somewhat surprising, as I would expect
(named (not (pos? -1)) "The amount should be positive")
Now, I can certainly "unwrap" the result and propagate the correct error message to the client.
My question is, wether this is part of the public API contract and whether we can safely rely on this behaviour.
Thanks,
Laszlo