I'm not sure how to word my question, so apologies if it's confusing. I'm currently trying to write specs for some data that's coming out of datomic. A map I'm getting back might look like:
{:id "123abc" :event/date "1/1/2020"}
My goal is to write a spec like:
(s/def ::result (s/keys :req-un [::id string? :event-date string?]))
I've tried a couple things, and have setup a namespace schema.event
where I'm defining the spec for date.
(ns schema.event)
(s/def :event/date string?)
The issue is that none of these work, I can't seem to get it to work with data containing event/date
as it keeps validating on just :date
.
The following will return success with my current setup:
{:id "123abc" :date "1/1/2020"}
But that doesn't mirror the data I'm getting from Datomic so isn't very helpful. What am I doing wrong here? I suspect it's just something to do with my lack of understand on how Clojure is treating namespaces.
That's because you're using the :req-un
option. Try switching to the :req
one. And you can have both - :req-un
for ::id
and :req
for :event/date
.