-
-
Save eyston/c797efc5e4c07304e0c331b97decd107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(s/def ::field-name (s/conformer (fn [x] | |
(cond | |
(keyword? x) | |
{:name x :arguments nil} | |
(and (list? x) | |
(keyword? (first x)) | |
(map? (second x))) | |
(let [[name args] x] | |
{:name name :arguments args}) | |
:else ::s/invalid)))) | |
(s/def ::field-name (s/and (s/or :simple keyword? | |
:args (s/cat :name keyword? :args map?)) | |
(s/conformer | |
(fn [[type conform]] | |
(case type | |
:simple {:name conform} | |
:args conform)) | |
(fn [{:keys [name args] :as conform}] | |
(if (seq args) | |
[:args conform] | |
[:simple name]))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment