Fork me on GitHub
#clojure-spec
<
2017-01-14
>
richiardiandrea00:01:10

so let's say I am enriching a data structure with chained transformations (`map`-ing or specter-ing)...and I want to spec every substep. For instance the first step has {:family {:name "bla"}} the second step will have {:family {:name "bla" :id :sda}}.

richiardiandrea00:01:18

how can I spec the second step after having already spec-ed the first as:

(s/def :family/entity (s/keys :req-un [:family/name]))
(s/def :family/family :family/entity)
(s/def :root/entity (s/keys :req-un  [:family/family]))

richiardiandrea00:01:53

now it should be ok

richiardiandrea00:01:52

so basically I'd need to add another spec adding :family/id but I can't see how to do it without overriding the :family/family spec

richiardiandrea00:01:07

ok I could change the namespace probably

eggsyntax00:01:16

Can you s/merge the :family/family spec with a new one which only specifies the new element?

richiardiandrea00:01:48

maybe šŸ˜„ let me try that

richiardiandrea00:01:23

but then I still need to change the namespace in the register

eggsyntax00:01:48

You could eval the s/def with a modified nameā€¦although having been doing a lot of it, Iā€™ll warn you that thatā€™s a route that can get reeeaaally sticky pretty fast. & there seem to be issues with evaling s/merge (thatā€™s where I stopped today, had to call a halt. In fact, crap, what am I doing here? Going AFK immediately šŸ˜‰ )

richiardiandrea00:01:06

it works, but now for each transformation I need:

(s/def :entity-with-id/family (s/merge :family/entity (s/keys :req-un [:family/id])))
(s/def :entity-with-id/definitions (s/keys :req-un [:entity-with-id/family]))

richiardiandrea00:01:36

so the namespace becomes the name of the transformation I want to target

triss13:01:29

hey all. is there a handy spec i can use for things that can be passed to s/valid? for testing?

triss13:01:15

i.e. name-spaced keywords, single-arity fnā€™s and specs I guess

gfredericks18:01:57

aren't specs just either of the first two?

bbloom21:01:21

is there something like ā€œmerge, but make all the keys optionalā€?

bbloom21:01:31

or i guess optionally-merge?

bbloom21:01:43

not sure what i mean / want šŸ˜›

bbloom22:01:45

also thinking aloud: i kinda want a predicate that is basically any? but means ā€œnot yet specā€™d"

rickmoynihan23:01:49

@bbloom (def not-specd-yet? any?)