schema

ben.mumford 2018-04-23T15:12:40.000055Z

hi all, i have a value and i want to check it is a map which can have any values except a specific few. how best to do this?

ben.mumford 2018-04-23T15:13:15.000606Z

something knarly like this: (s/pred #(and (map? %) (empty? (some #{:a :b} (keys %)))))

tanzoniteblack 2018-04-23T17:11:20.000180Z

@ben.mumford620 I probably would implement it with constrained:

(schema/constrained {schema/Any schema/Any}
                    (fn [m]
                      (empty? (clojure.set/intersection (set (keys m))
                                                        #{:alpha :beta})))
                    "Can't contain certain keys")

tanzoniteblack 2018-04-23T17:12:12.000102Z

the actual function checking for certain keys could of course be done with some like you did instead of intersection