Fork me on GitHub
#clojure-spec
<
2017-05-28
>
bbss14:05:28

I'm developing web stuff in cljc with spec and loving it. It's so great to start out with some specs and to generate sample data and build out your front-end from there.

bbss14:05:05

they can double as react-props with {pre [(valid? spec state)]}

bbss14:05:30

one thing I'm hitting now is I'd like to generate ids so I can give those as unique react keys, which is necessary when react displays lists. Since I will eventually replace the sample data ids with :db/id from datascript, I figured I can add uuid as spec pred and have that generate unique id's. But that doesn't match what datascript generates for ids.

bbss14:05:53

those are just ints. Is there a way to generate unique ints?

bbss15:05:14

I think I'll have to write my own generator for that

bbss15:05:08

I've tried with s/or, which would work for the validation but it also generates random (non unique) ints. As it should of course 🙂