Fork me on GitHub
#clojure-spec
<
2016-11-24
>
ikitommi06:11:08

Runtime defined specs/schemas have also a good use case with web apis & dynamic forms. I’m thinking of creating a MapSpec -kinda Spec Record which would allow non-registered (global) specs to be used and which could manipulated as normal Clojure Map. Adding generated specs to registry at runtime might not be a good idea...

ikitommi06:11:33

Related: toyed with a simple collection spec macro that allows specs to be created from nested maps/vectors/sets. Should help to define partially anonymous map specs. For things like http query-parameters.

ikitommi06:11:54

emits just recursively s/keys & s/coll-ofs.

ikitommi07:11:34

Hmm... but I think after runtime modification of a MapSpec, one would still need to have the full source-code of it for the s/form to work. So adding values at runtime would require both the value and it’s source code to be added. Removing keys would be easy, same as merging existing MapSpecs. Maybe not such a good idea after all.

rickmoynihan10:11:29

ikitommi: Interesting - I was having similar thoughts about the possibility of building more specialised libraries that can consume ::specs - for more dynamic use cases… e.g. you could imagine something like plumatic being able to consume specs in some circumstances- It seems you’re a long way ahead of me 🙂

rickmoynihan10:11:50

still very much at the getting started stage with spec

ikitommi14:11:17

rickmoynihan: we are all still spec newbies, exiting times.

yonatanel18:11:36

@ikitommi Talk to me about that runtime specs you are planning. I've just written down my requirements for this kind of thing yesterday and would love to collaborate.