clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
ballpark 2021-06-04T21:13:37.057600Z

How do I do an ::Anything spec in Clojurescript? In Clojure I have (s/def ::Anything #(instance? Object %))

borkdude 2021-06-04T21:14:35.057800Z

@ballpark any?

borkdude 2021-06-04T21:15:15.058200Z

note that your ::Anything spec will not tolerate nil

ballpark 2021-06-04T21:16:27.059100Z

Thanks, Yeah, I'll have to do a parity match on those

borkdude 2021-06-04T21:17:13.059500Z

just to be clear: the answer in both dialects is any?.

ballpark 2021-06-04T21:22:04.061400Z

right, thanks, here's what I changed it to for my cljc file: (s/def ::Anything #(s/and some? any?)) This way I can specify s/nilable in the specs that reference ::Anything. Seem like an ok solution to you?

borkdude 2021-06-04T21:24:50.062300Z

it seems a little weird to me. why not just use some? and any? directly?

ballpark 2021-06-04T21:25:42.063Z

Yes, that's it! Something seemed wrong to me too, thanks again!

2021-06-04T23:59:19.063400Z

s/and with any? as an item is exactly equivalent to just the rest of the items