Fork me on GitHub
#clojure-spec
<
2018-09-27
>
seancorfield00:09:25

You're only reading the last part of the failure -- the first part says "2018-09-26T21:47:57.304Z" fails spec: :io.cloudrepo.signup.email/creation-timestamp

4
seancorfield00:09:53

So you have an ::email/creation-timestamp spec and that string fails to conform to it.

seancorfield00:09:46

Since that fails, the whole :success part fails and the the whole hashmap fails the :not-found part -- the val in explain is the whole hash map, not just the creation timestamp string.

seancorfield00:09:30

s/keys will conform/validate any keys that are provided that have a corresponding spec, not just the listed :req keys.

Chris00:09:12

Ah, that makes sense now

Chris00:09:36

I didn't even check to see if the timestamp was okay because I didn't care about it

Chris00:09:55

but I guess that's good because it will catch where you create bad data at the first possible point

Chris00:09:02

rather than when you explicitly check, right?

seancorfield00:09:06

Yup. The assumption is that specs should apply wherever those uniquely-name keys appear.

seancorfield00:09:39

If you're using unqualified keys, you won't run into that -- since only the :req-un and :opt-un keys will map to specs.

Chris00:09:57

Okay, thanks Sean - you're always super helpful!

😸 4
lilactown22:09:27

I have this spec:

(spec/cat :op #{:jdbc/insert}
            :table keyword?
            :row map?)
for a data structure like [:jdbc/insert :foo {:bar "baz"}]. how would I add an optional 4th element at the end?

seancorfield23:09:26

:options (s/? ::opt-spec)

seancorfield23:09:05

(assuming you wanted to optionally pass in an options map of some sort @lilactown)

4