Last active
January 4, 2018 13:04
-
-
Save abp/0c4106eba7b72802347b 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
(require '[schema.core :as s]) | |
(require '[schema.coerce :as coerce]) | |
(require '[schema.utils :as utils]) | |
(defn filter-schema-keys | |
[m schema-keys extra-keys-walker] | |
(reduce-kv (fn [m k v] | |
(if (or (contains? schema-keys k) | |
(and extra-keys-walker | |
(not (utils/error? (extra-keys-walker k))))) | |
m | |
(dissoc m k))) | |
m | |
m)) | |
(defn map-filter-matcher | |
[s] | |
(when (or (instance? clojure.lang.PersistentArrayMap s) | |
(instance? clojure.lang.PersistentHashMap s)) | |
(let [extra-keys-schema (#'s/find-extra-keys-schema s) | |
extra-keys-walker (when extra-keys-schema (s/walker extra-keys-schema)) | |
explicit-keys (some->> (dissoc s extra-keys-schema) | |
keys | |
(mapv s/explicit-schema-key) | |
(into #{}))] | |
(when (or extra-keys-walker (seq explicit-keys)) | |
(fn [x] | |
(if (map? x) | |
(filter-schema-keys x explicit-keys extra-keys-walker) | |
x)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @abp, can you contact me from [email protected]. I'm interesting in to take your Github account name (abp) for our open source asp.net boilerplate project (https://github.com/aspnetboilerplate/aspnetboilerplate) if we can make a deal.
Thanks.