simple implementation of unwrapping dataspecs from specs created usin…#226
simple implementation of unwrapping dataspecs from specs created usin…#226wandersoncferreira wants to merge 3 commits intometosin:masterfrom
Conversation
|
Could not lose the opportunity to write a property-based test for the I still don't totally get how a specific portion of a spec will be converted. The current solution has lots of hacks that I can probably clean up, the fact of existing so many ways to check and or create a spec is already complicated to me, 2020-04-09 EDIT: From my side, this is now ready to merge. If the drawbacks mentioned above is fine for you. |
Hello @ikitommi , I found a nice ticket open (#111 ) and I wanted to give it a shot. This is a simplified implementation of unwrapping specs created from data-specs. I used multimethods to dispatch to common spec operators, but the current solution is not exhaustive therefore might have some possibilities not covered, need to check this out.
Some drawbacks.
cljbasically because I can't get the function out of symbols incljs(this situation again). I run the test in cljs and got the following error message for the simpler specs I wrote:As seems like cljs compile the
boolean?function to a js object and I get aSymbolback fromresolvemacro in cljs.As we can see the
::agekeyword was transformed to a full form asclojure.core/post-int?therefore when I use(ds/unspec (ds/spec {:name ::test :spec ::age})) ;;=> #function[clojure.core/pos-int?]It works, but is not the same as recovering the full qualified keyword that defined the pos-int? in the first place.
TODO: I would like to present this rationale for the solution to see if is viable in the long run, as well as discuss the
unspecarity [I don't see why not only receive the spec itself, idk what kind of parameters would be nice to have as well]. After, I need to implement,ds/optandds/reqover map keys.Thanks!