plumatic / schema

Clojure(Script) library for declarative data description and validation
Other
2.41k stars 257 forks source link

Optional element in sequences #348

Open jenshweber opened 8 years ago

jenshweber commented 8 years ago

Hello, I am trying to understand the behaviour of the option element in the FancySeq example on the Readme page. The following throws a validation error:

(s/validate FancySeq ["test" 1 2 3])

Why is this so? I think it should validate fine, since they keyword is optional. Is this a bug, or do I fail to understand the notion of optionality? Thanks Jens

w01fe commented 8 years ago

Not a bug, the semantics is that if an optional element is not present, the sequence must stop there. I.e. in regex it's like (o1 (o2 r)?)? not o1? o2? r

We will try to clarify that in the readme, or if you want to take a crack at it that would be even better :). Thanks!

On Fri, Mar 18, 2016, 4:56 AM Jens Weber notifications@github.com wrote:

Hello, I am trying to understand the behaviour of the option element in the FancySeq example on the Readme page. The following throws a validation error:

(s/validate FancySeq ["test" 1 2 3])

Why is this so? I think it should validate fine, since they keyword is optional. Is this a bug, or do I fail to understand the notion of optionality? Thanks Jens

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/plumatic/schema/issues/348