Fork me on GitHub
#clojure-spec
<
2019-06-22
>
carkh21:06:13

i have this spec : (s/cat :tag ...... :children (s/* ::child) I have a special case where i want a single child, but i still want it to be conformed as a list of one item.... how would i express this ?

carkh21:06:03

i have the dispatching ok,, been using conformer and it works, but it swallows the explaining of errors down the tree

carkh21:06:07

so what i would want is a replacement for s/* i guess

seancorfield22:06:48

s/+ — one or more.

seancorfield22:06:09

Maybe wrapped in s/and to check the count is 1?

seancorfield22:06:32

Not sure how s/and combines with the sequence regex stuff tho’… I’d have to experiment.

carkh23:06:22

oh i can try that thanks

carkh23:06:07

not working for me but that was a good try =)

carkh23:06:40

i'm really trying to use spec as a parser for sexp, but it's not actually one, i guess the limitations are due to the gen part

carkh23:06:56

This works, but the real thing is not doing integers, and the tree may be deep. so finding a syntax error deep down might be hard without proper explaining from spec

carkh23:06:50

ahhaaa ! this might work

carkh23:06:09

and i get nice errors deep down the tree, nice