clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
zane 2020-01-18T00:03:50.026900Z

True.

zane 2020-01-18T00:04:29.027100Z

I guess I’m still struggling with which kinds of “parsing” are appropriate to do with spec and which aren’t.

zane 2020-01-18T00:05:03.027300Z

Differentiating between different shapes of data seems like something you could achieve with it via s/or and s/conform.

zane 2020-01-18T00:05:19.027500Z

But you could also do that kind of thing with match, or with plain old Clojure.

dharrigan 2020-01-18T14:45:22.028200Z

Is there an example of how I might use spec to ensure that a field is in OffsetDateTime format?

alexmiller 2020-01-18T15:07:23.028600Z

#(instance? OffsetDateTime %) ?

dharrigan 2020-01-18T15:10:02.028800Z

oooh

dharrigan 2020-01-18T15:10:10.029Z

will try that

dharrigan 2020-01-18T15:20:06.029500Z

Sorta gets me there, the field is a string, so I think I'll have to do some extra magic

alexmiller 2020-01-18T15:33:58.029800Z

probably need to use a parser then

alexmiller 2020-01-18T15:34:12.030200Z

which is part of the java time library

dharrigan 2020-01-18T15:34:21.030400Z

kk

dharrigan 2020-01-18T15:34:28.030700Z

thanks for the pointer 🙂