Yo Seth,
Thanks for the clarification. I didn't realize full schemas were
allowed as values to type! So this addresses my concern about
flexibility, but not simplicity.
A question that arises is then for your example:
{ id: "toy1", type: "string", minLength: 3, maxLength: 10 }
{ id: "toy2", type: "integer", minimum: 0, maximum: 42 }
{
type: [ "toy1", "toy2" ],
minLength: 5,
minimum: 2
}
isn't this the same as:
{
type: [ { extends: "toy1", minLength: 5},
{ extends: "toy2", minimum: 2] ]
}
More directly I guess I'm wondering, The ability to have both distinct
constraints and common constraints in the case of a union schema
definition seems to have no utility, and makes the grammar more
complex. There must be an example I'm missing where that feature adds
expressivity. otherwise things could get simplified down to this:
[ { extends: "toy1", minLength: 5},
{ extends: "toy2", minimum: 2] ]
(if a schema is an array, then it is a union type)
am I now missing something else? :)
lloyd