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
Added name to data spec #125
Added name to data spec #125
Conversation
Is this planned for some release of sorts?
As you can see, expound names specs in error as nil. |
Thanks for the PR and sorry for the lag, got buried after vacations. Would like to merge this, but the tests don't pass. Could you fix them? |
I'll try to solve it with fewer changed lines if possible, we'll see. |
I also realized my solution might not be the best possible way of doing it. I couldn't have time to think thoroughly. |
I think it could be enough to put the name into response of |
It seems that just assoc'in the |
If you would like to copy the #132 changes into this PR, would be happy to merge this and remove my test branch. Or, I can do it other way around. |
I didn't understand why we can't do this to non-map specs. If I'm able to assoc a name after I create the spec, it should also be possible to add it anyway within the spec-tools, or maybe I'm missing something. (def my-spec
(assoc
(ds/spec {:name ::my-spec
:spec [[int?]]})
:name ::my-spec))
(st/spec-name my-spec)
;; => core/my-spec |
You're correct, all top-level specs of any type and direct map value specs should have a name. But specs wrapped in internal collections can't have a name as they can't have unique names as they don't accumulates anything to the name. example1(ds/spec :user/kikka [[int?]])
example2(ds/spec ::kikka [{:a [[{:b int?]]}])
... hopefully got that correct. in brief: just don't push the name into a spec if the name is already been given to a spec under the data-spec, meaning non-top-level collections of any kind. I think. |
FIxed this with #140 |
Fixes #124
Adds name to data spec when a name is provided during creation.
Example: