I want a spec that accepts nilable values but does not generate them. So far I'm going with a macro like the following. Is there a better way to do this? Is wanting to do this an indicator that I'm making a bad design decision? The motivation is that I'm working with a db schema that allows NULL but my validation on data coming from users will prevent incoming nil values. I want my generators to simulate user-supplied data going into the DB and not data coming out of the existing DB.
seems ok to me
(defmacro def-spec-nilable-non-nilable-generator
[kw spec]
`(s/def ~kw
(s/with-gen
(s/nilable ~spec)
(constantly (s/gen ~spec)))))
Does anybody know of anything resembling linear temporal logic (or something weaker but still useful for describing sequences) for spec?
I do not know if this is anywhere near what you are looking for, but a Google search for the terms "clojure linear temporal logic" turned up this project: https://github.com/esb-lwb/lwb
Spec I am sure has nothing built in for this, except the general purpose escape hatch of letting you use arbitrary functions you write that return true/false as specs -- which is a huge enabler for anything you can write code for.
It won't necessarily help you generate random instances satisfying that function -- that is separate work you would need to do if you wanted that capability.