Fork me on GitHub
#clojure-spec
<
2017-01-22
>
andrewzhurov08:01:15

thread here whooo

andrewzhurov08:01:42

I more than sure that those questions appear often here, so, some links ?

settinghead14:01:09

for those interested in seeing another javascript port of clojure.spec (in additon to js.spec), here is one I've made: https://github.com/clausejs/clausejs. Regex specs and fspecs are currently working. Data generation comes next. I've also made a spec documentation generator called clausejs-docgen (still WIP), which I have been using to generate Clause.js's own documentation. Lastly, there is a syntax function which takes in an fspec, enumerates over all of its arguments' possibilities, and outputs a concise list of lambda-ish syntax references (you can find examples in the doc site here: https://clause.js.org)

mrg23:01:21

Does anyone have any examples on how clojure.spec/conformer works? I am trying to coerce a json map (including UUIDs and instants, and seqs of keywords) and I cannot find any good examples anywhere

Oliver George23:01:10

I don't think it's really intended to use conform in that way

Oliver George23:01:28

as best I understand it, spec is intended to describe static data rather than the coerce data

Oliver George23:01:29

Technically that looks a bit like coercion in that the conformed data is a different shape.

Oliver George23:01:35

Hope that helps.

seancorfield23:01:21

@mrg I answered in #clojure but I'll respond to @olivergeorge's comment: yes, you generally want to be very wary of specs that coerce data because then every "client" of that spec has to accept the coercion. So it's only good for a spec where you always want all "clients" to see the same coercion too.