-
Notifications
You must be signed in to change notification settings - Fork 13
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
Compose spec #51
Comments
So you're saying neither |
It is more on the composition of each individual spec, where one just adds fields on top of the other. In Clojure spec there is a (s/def :animal/kind string?)
(s/def :animal/says string?)
(s/def :animal/common (s/keys :req [:animal/kind :animal/says]))
(s/def :dog/tail? boolean?)
(s/def :dog/breed string?)
(s/def :animal/dog (s/merge :animal/common (s/keys :req [:dog/tail? :dog/breed])))
(s/valid? :animal/dog
{:animal/kind "dog"
:animal/says "woof"
:dog/tail? true
:dog/breed "retriever"}) |
Does this only apply to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One of the great features of
clojure.spec
is the ability of merging specs, because they are essentially data (ok macros are still in the way, but nothing is perfect).At the moment
js.spec
does not do that, but it would be great if we could do something like:Ok the example does not make too much sense, but we should be composing and reusing specs.
...I have had a look at the code and this is actually a big shift because of the use of
class
...still think is worth doing it...maybe theS.merge
function can just merge the fields...The text was updated successfully, but these errors were encountered: