Fork me on GitHub

In that case, I'd prefer something like (s/coll-of (fn [[k v]] (= k (keyword (:name v)))))


cheers! I like that too

Charles Fourdrignier12:01:24

Hello, I would like to write a client for testing some servers' responses. Not for production purpose, but for coding events like coderetreats (inspired by I'm trying to implement this with Clojure (http-kit) and think to Clojure Spec as a validator. I'm a beginner with Clojure and Clojure Spec and I don't know if it's a "good" idea, absolutely ridiculous or in the "Clojure's spirit". I write two specs to demonstrate the concept. I would appreciate any feedback about the idea, code...


I don’t see any problem with the idea of using spec to validate responses. Depending on how you intend to use the spec, there may be some ways you can improve it so you get better error messages when it fails.


For instance, it might be useful to use a multi-spec here or maybe use s/or so you can figure out which case matched with conform. It depends on whether you want to just make sure the response is any type of valid response (i.e. 200 and 404 will both be OK, as long as well formed) or if you want to use spec to determine if a response was successful or not

Charles Fourdrignier16:01:13

Thank a lot for your ideas.


what can be the reason that explain is successful on an invalid conform?


when I get it, i restart my repl.


what's the spec?


i found the 'syntax-error' in the data, so i'm going to try to narrow it down


on a side note seems like that one still breaks


(fn [_] :clojure.spec.alpha/invalid)


oh, maybe not then, it just broke in my repl, hmm


That's why it works here @mpenet


@alexmiller I heard Rich mention in his last talk that next version Spec would be more "programmable" or something like that. Is there anything more I can read about that? Or can I ask about specifics?


my guess: either it's something related to with unforming that re-creates a new spec, or something entirely new


@mpenet Thanks, for the pointer.

Alex Miller (Clojure team)16:01:16

Nothing to read yet and not related to 2112