Currently s/enum will check for strict equivalent in a set of string enum. Is there away that we can have a case-insensitive version?
(def schema (s/enum ["SUCCESS", "FAILURE"]
i.e. "Success" can be coerce validated to "SUCCESS"
One way I was thinking is to create a new schema:
(defrecord CaseInsensitiveEnumSchema [vs]
Schema
(spec [this] (leaf/leaf-spec (spec/precondition this #(contains? vs (.toUpperCase %)) #(list vs %))))
(explain [this] (cons 'case-insensitive-enum vs)))
(defn case-insensitive-enum
"A value that must be = to some element of vs."
[& vs]
(EnumSchema. (set vs)))
That works for validation i.e. (s/validate schema "Success") => "Success".
But it doesn't work for generating swagger automatically.
Thanks.