Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strict-keys doesn't work with spec/merge #1

Closed
cldwalker opened this issue Sep 26, 2016 · 2 comments
Closed

strict-keys doesn't work with spec/merge #1

cldwalker opened this issue Sep 26, 2016 · 2 comments

Comments

@cldwalker
Copy link

Hi. Nice library. We've invented something similar to strict-keys internally at work. Does your library have any goals around being clj/cljs compatible? Also, I noticed that specs defined with strict-keys don't validate correctly when merged into a parent spec (see example below). Is that a use case you're interested in?
Cheers

Failing example:

user=> (s/def ::a int?)
:user/a
user=> (s/def ::b keyword?)
:user/b
user=> (s/def ::foo (ss/strict-keys :req-un [::a]))
:user/foo
user=> (s/def ::bar (ss/strict-keys :req-un [::b]))
:user/bar
user=> (s/def ::baz (s/merge ::foo ::bar))
:user/baz
user=> (s/explain ::baz {:a 1 :b :k})
val: {:a 1, :b :k} fails spec: :user/foo at: [:unknown-key :b] predicate: (every? #{:a} (keys %))
         :strictly-specking.core/keys->specs  {:a :user/a}
         :strictly-specking.core/unknown-key  :b
val: {:a 1, :b :k} fails spec: :user/bar at: [:unknown-key :a] predicate: (every? #{:b} (keys %))
         :strictly-specking.core/keys->specs  {:b :user/b}
         :strictly-specking.core/unknown-key  :a
nil
@bhauman
Copy link
Owner

bhauman commented Sep 26, 2016

Yeah this will not be able to work with merged specs. Strict spec is saying that this is the set of valid keys period. You can't expand a strict set.

Right now this is really just intended for internal use.. I'm waiting for spec to be finalized before putting anymore energy into this. It's main use is for configuration validation.

@cldwalker
Copy link
Author

Good to know. Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants