Fork me on GitHub
#clojure-spec
<
2018-01-09
>
athos07:01:07

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

dadair18:01:13

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 https://github.com/rchatley/extreme_startup). 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. https://gist.github.com/Charlynux/35c754f3f213012397da8ae61b97cb1c I would appreciate any feedback about the idea, code...

bbrinck15:01:20

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.

bbrinck15:01:33

For instance, it might be useful to use a multi-spec here https://clojure.org/guides/spec#_multi_spec 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.

stijn12:01:01

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

souenzzo12:01:07

when I get it, i restart my repl.

mpenet12:01:00

what's the spec?

stijn12:01:19

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

mpenet12:01:11

on a side note seems like that one still breaks

mpenet12:01:25

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

mpenet12:01:51

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

madstap13:01:00

That's why it works here @mpenet

bhauman15:01:26

@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?

mpenet16:01:50

my guess: either it's something related to https://dev.clojure.org/jira/browse/CLJ-2112 with unforming that re-creates a new spec, or something entirely new

bhauman16:01:11

@mpenet Thanks, for the pointer.

Alex Miller (Clojure team)16:01:16

Nothing to read yet and not related to 2112