Skip to content

Commit a0510f0

Browse files
committed
More
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent a4fdba5 commit a0510f0

43 files changed

Lines changed: 299 additions & 319 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

content/2019-09/applicator/additionalProperties.markdown

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,33 @@ related:
4343

4444
The `additionalProperties` keyword restricts object instance properties not
4545
described by the _sibling_ [`properties`]({{< ref
46-
"2020-12/applicator/properties"
47-
>}}) and [`patternProperties`]({{< ref "2020-12/applicator/patternproperties"
48-
>}}) keywords (if any), to validate against the given subschema. Information
49-
about the properties that this keyword was evaluated for is reported using
50-
annotations.
46+
"2019-09/applicator/properties" >}}) and [`patternProperties`]({{< ref
47+
"2019-09/applicator/patternproperties" >}}) keywords (if any), to validate
48+
against the given subschema. Information about the properties that this keyword
49+
was evaluated for is reported using annotations.
5150

5251
{{<common-pitfall>}}The use of the [`properties`]({{< ref
53-
"2020-12/applicator/properties" >}}) keyword **does not prevent the presence of
54-
other properties** in the object instance and **does not enforce the presence
55-
of the declared properties**. In other words, additional data that is not
56-
explicitly prohibited is permitted by default. This is intended behaviour to
57-
ease schema evolution (open schemas are backwards compatible by default) and to
58-
enable highly-expressive constraint-driven schemas.
59-
60-
If you want to restrict instances to only contain the properties you declared,
61-
you must set this keyword to the boolean schema `false`, and if you want to
62-
enforce the presence of certain properties, you must use the [`required`]({{<
63-
ref "2020-12/validation/required" >}}) keyword accordingly.
52+
"2019-09/applicator/properties" >}}) keyword **does not prevent the presence
53+
of other properties** in the object instance and **does not enforce the
54+
presence of the declared properties**. In other words, additional data that
55+
is not explicitly prohibited is permitted by default. This is intended
56+
behaviour to ease schema evolution (open schemas are backwards compatible by
57+
default) and to enable highly-expressive constraint-driven schemas.
58+
59+
If you want to restrict instances to only contain the properties you
60+
declared, you must set this keyword to the boolean schema `false`, and if you
61+
want to enforce the presence of certain properties, you must use the
62+
[`required`]({{< ref "2019-09/validation/required" >}}) keyword accordingly.
6463
{{</common-pitfall>}}
6564

6665
{{<learning-more>}}While the most common use of this keyword is setting it to
67-
the boolean schema `false` to prevent additional properties, it is possible to
68-
set it to a satisfiable schema. Doing this, while omitting the
69-
[`properties`]({{< ref "2020-12/applicator/properties" >}}) and
70-
[`patternProperties`]({{< ref "2020-12/applicator/patternproperties" >}})
66+
the boolean schema `false` to prevent additional properties, it is possible
67+
to set it to a satisfiable schema. Doing this, while omitting the
68+
[`properties`]({{< ref "2019-09/applicator/properties" >}}) and
69+
[`patternProperties`]({{< ref "2019-09/applicator/patternproperties" >}})
7170
keywords, is an elegant way of describing how the value of every property in
72-
the object instance must look like independently of its
73-
name.{{</learning-more>}}
71+
the object instance must look like independently of its name.
72+
{{</learning-more>}}
7473

7574
{{<constraint-warning `object`>}}
7675

content/2019-09/applicator/allOf.markdown

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,22 @@ conjunction](https://en.wikipedia.org/wiki/Logical_conjunction) (AND)
3535
operation, as instances are valid if they satisfy every constraint of every
3636
subschema (the intersection of the constraints).
3737

38-
{{<common-pitfall>}} Wrapping a single instance of the [`$ref`](../../core/ref)
39-
or [`$dynamicRef`](../../core/dynamicref) keyword in an `allOf` operator is an
38+
{{<common-pitfall>}} Wrapping a single instance of the [`$ref`]({{< ref
39+
"2019-09/core/ref" >}}) or [`$recursiveRef`]({{< ref
40+
"2019-09/core/recursiveref" >}}) keyword in an `allOf` operator is an
4041
anti-pattern.
4142

4243
This practice has historical roots. In JSON Schema [Draft 7](/draft7) and
43-
earlier versions, any subschema declaring the `$ref` keyword was considered to
44-
be a _reference object_ and any other sibling keyword was silently ignored. As
45-
a consequence, subschemas with references that made use of other keywords had
46-
to artificially wrap the reference into its own subschema.
44+
earlier versions, any subschema declaring the `$ref` keyword was considered
45+
to be a _reference object_ and any other sibling keyword was silently ignored.
46+
As a consequence, subschemas with references that made use of other keywords
47+
had to artificially wrap the reference into its own subschema.
4748
{{</common-pitfall>}}
4849

4950
{{<best-practice>}}This keyword typically has a single use case: combining
5051
_multiple_ schemas through the use of (internal or external) references. If
51-
this is not the case, prefer elevating the keywords of every subschema to the
52-
outer schema and avoid using this keyword. {{</best-practice>}}
52+
this is not the case, prefer elevating the keywords of every subschema to
53+
the outer schema and avoid using this keyword. {{</best-practice>}}
5354

5455
This keyword is equivalent to the `&&` operator found in most programming
5556
languages. For example:

content/2019-09/applicator/anyOf.markdown

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ related:
2929
The {{<link keyword="anyOf" vocabulary="applicator">}} keyword restricts
3030
instances to validate against _at least one_ (but potentially multiple) of the
3131
given subschemas. This keyword represents a [logical
32-
disjunction](https://en.wikipedia.org/wiki/Logical_disjunction) (OR) operation,
33-
as instances are valid if they satisfy the constraints of one or more
34-
subschemas (the union of the constraints).
32+
disjunction](https://en.wikipedia.org/wiki/Logical_disjunction) (OR)
33+
operation, as instances are valid if they satisfy the constraints of one or
34+
more subschemas (the union of the constraints).
3535

3636
{{<learning-more>}}Keep in mind that when collecting annotations, the JSON
3737
Schema implementation will need to exhaustively evaluate every subschema past
38-
the first match instead of short-circuiting validation, potentially introducing
39-
additional computational overhead.
38+
the first match instead of short-circuiting validation, potentially
39+
introducing additional computational overhead.
4040

4141
For example, consider 3 subschemas where the instance validates against the
4242
first. When not collecting annotations, validation will stop after evaluating
43-
the first subschema. However, when collecting annotations, evaluation will have
44-
to proceed past the first subschema in case the others emit
43+
the first subschema. However, when collecting annotations, evaluation will
44+
have to proceed past the first subschema in case the others emit
4545
annotations.{{</learning-more>}}
4646

4747
This keyword is equivalent to the `||` operator found in most programming

content/2019-09/applicator/dependentSchemas.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ related:
2222

2323
The `dependentSchemas` keyword restricts object instances to validate against
2424
one or more of the given subschemas if the corresponding properties are
25-
defined. Note that the given subschemas are evaluated against the object that
26-
defines the property dependency.
25+
defined. Note that the given subschemas are evaluated against the object
26+
that defines the property dependency.
2727

2828
{{<learning-more>}}The [`dependentRequired`]({{< ref
29-
"2020-12/validation/dependentrequired" >}}) keyword is a specialisation of this
30-
keyword to describe object dependencies that only consist in property
29+
"2019-09/validation/dependentrequired" >}}) keyword is a specialisation of
30+
this keyword to describe object dependencies that only consist in property
3131
requirement.{{</learning-more>}}
3232

3333
{{<constraint-warning `object`>}}

content/2019-09/applicator/else.markdown

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ instances to validate against the given subschema if the {{<link keyword="if"
3434
vocabulary="applicator">}} sibling keyword failed to validate against the
3535
instance.
3636

37-
{{<common-pitfall>}} This keyword has no effect if the [`if`]({{< ref "if" >}})
38-
keyword is not declared within the same subschema. {{</common-pitfall>}}
37+
{{<common-pitfall>}} This keyword has no effect if the [`if`]({{< ref
38+
"2019-09/applicator/if" >}}) keyword is not declared within the same
39+
subschema. {{</common-pitfall>}}
3940

40-
{{<best-practice>}} The [`if`]({{< ref "if" >}}), [`then`]({{< ref "then" >}}),
41-
and [`else`]({{< ref "else" >}}) keywords can be thought of as imperative
42-
variants of the [`anyOf`]({{< ref "anyOf" >}}) keyword, and both approaches are
43-
equally capable of describing arbitrary conditions. Choose the one that more
44-
elegantly describes your desired constraints.{{</best-practice>}}
41+
{{<best-practice>}} The [`if`]({{< ref "2019-09/applicator/if" >}}),
42+
[`then`]({{< ref "2019-09/applicator/then" >}}), and `else` keywords can be
43+
thought of as imperative variants of the [`anyOf`]({{< ref
44+
"2019-09/applicator/anyof" >}}) keyword, and both approaches are equally
45+
capable of describing arbitrary conditions. Choose the one that more elegantly
46+
describes your desired constraints.{{</best-practice>}}
4547

4648
## Examples
4749

content/2019-09/applicator/if.markdown

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@ vocabulary="applicator">}} sibling subschemas (if present). Note that the
3434
evaluation outcome of this subschema controls which other subschema to apply
3535
(if any) but has no direct effect on the overall validation result.
3636

37-
{{<best-practice>}} The [`if`]({{< ref "if" >}}), [`then`]({{< ref "then" >}}),
38-
and [`else`]({{< ref "else" >}}) keywords can be thought of as imperative
39-
variants of the [`anyOf`]({{< ref "anyOf" >}}) keyword, and both approaches are
40-
equally capable of describing arbitrary conditions. Choose the one that more
41-
elegantly describes your desired constraints.{{</best-practice>}}
37+
{{<best-practice>}} The `if`, [`then`]({{< ref "2019-09/applicator/then"
38+
>}}), and [`else`]({{< ref "2019-09/applicator/else" >}}) keywords can be
39+
thought of as imperative variants of the [`anyOf`]({{< ref
40+
"2019-09/applicator/anyof" >}}) keyword, and both approaches are equally
41+
capable of describing arbitrary conditions. Choose the one that more elegantly
42+
describes your desired constraints.{{</best-practice>}}
4243

4344
{{<learning-more>}} This keyword has no effect if neither the [`then`]({{< ref
44-
"then" >}}) nor [`else`]({{< ref "else" >}}) keywords are declared within the
45-
same subschema. However, when collecting annotations, the JSON Schema
46-
implementation will still need to evaluate the [`if`]({{< ref "if" >}}) keyword
47-
in case its subschema emits annotations.{{</learning-more>}}
45+
"2019-09/applicator/then" >}}) nor [`else`]({{< ref
46+
"2019-09/applicator/else" >}}) keywords are declared within the same subschema.
47+
However, when collecting annotations, the JSON Schema implementation will still
48+
need to evaluate the `if` keyword in case its subschema emits annotations.
49+
{{</learning-more>}}
4850

4951
The {{<link keyword="if" vocabulary="applicator">}}, {{<link keyword="then"
5052
vocabulary="applicator">}}, and {{<link keyword="else"
@@ -59,9 +61,10 @@ JSON Schema is a [constraint-driven
5961
language](https://modern-json-schema.com/json-schema-is-a-constraint-system).
6062
Therefore, omitting either the {{<link keyword="then"
6163
vocabulary="applicator">}} or the {{<link keyword="else"
62-
vocabulary="applicator">}} keywords is equivalent to setting the corresponding
63-
part of the ternary conditional operation to the boolean true. In other words,
64-
undefined consequent or alternative paths lead to success. For example:
64+
vocabulary="applicator">}} keywords is equivalent to setting the
65+
corresponding part of the ternary conditional operation to the boolean true.
66+
In other words, undefined consequent or alternative paths lead to success.
67+
For example:
6568

6669
```c
6770
// If `then` is missing

content/2019-09/applicator/items.markdown

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ related:
4545
The `items` keyword is used to validate array items and has two different modes
4646
of operation depending on its value:
4747

48-
**Schema Form**: When set to a schema, `items` validates that all items in the
49-
array instance validate against the given subschema. Whether this keyword was
50-
evaluated against any item of the array instance is reported using annotations.
51-
52-
**Array Form**: When set to an array of schemas, `items` validates each item in
53-
the array instance against the subschema at the corresponding position (tuple
54-
validation). Items beyond the length of the `items` array can be validated using
55-
the [`additionalItems`]({{< ref "2019-09/applicator/additionalitems" >}})
56-
keyword. The annotation reports the largest index to which a subschema was
57-
applied, or true if it was applied to every item.
48+
**Schema Form**: When set to a schema, `items` validates that all items in
49+
the array instance validate against the given subschema. Whether this keyword
50+
was evaluated against any item of the array instance is reported using
51+
annotations.
52+
53+
**Array Form**: When set to an array of schemas, `items` validates each item
54+
in the array instance against the subschema at the corresponding position
55+
(tuple validation). Items beyond the length of the `items` array can be
56+
validated using the [`additionalItems`]({{< ref
57+
"2019-09/applicator/additionalitems" >}}) keyword. The annotation reports the
58+
largest index to which a subschema was applied, or true if it was applied to
59+
every item.
5860

5961
{{<common-pitfall>}}This keyword does not prevent an array instance from being
6062
empty. If needed, use the [`minItems`]({{< ref "2019-09/validation/minitems"

content/2019-09/applicator/not.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ might seem counter-intuitive, consider the following cases:
4646
{{</learning-more>}}
4747

4848
{{<best-practice>}} Avoid the use of this keyword (usually negating the
49-
[`required`]({{< ref "/2020-12/validation/required" >}}) keyword) to prohibit
49+
[`required`]({{< ref "2019-09/validation/required" >}}) keyword) to prohibit
5050
specific object properties from being defined. Instead, use the
5151
[`properties`]({{< ref "properties" >}}) keyword and set the disallowed object
5252
properties to the `false` boolean schema.{{</best-practice>}}

content/2019-09/applicator/oneOf.markdown

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,25 @@ related:
2929
The {{<link keyword="oneOf" vocabulary="applicator">}} keyword restricts
3030
instances to validate against _exactly one_ (and only one) of the given
3131
subschemas and fail on the rest. This keyword represents a [logical exclusive
32-
disjunction](https://en.wikipedia.org/wiki/Exclusive_or) (XOR) operation. In
33-
practice, the vast majority of schemas don't require exclusive disjunction
32+
disjunction](https://en.wikipedia.org/wiki/Exclusive_or) (XOR) operation.
33+
In practice, the vast majority of schemas don't require exclusive disjunction
3434
semantics but a simple disjunction. If you are not sure, the {{<link
3535
keyword="anyOf" vocabulary="applicator">}} keyword is probably a better fit.
3636

3737
{{<common-pitfall>}}
3838

3939
Avoid this keyword unless you absolutely need exclusive disjunction
40-
semantics, which is rarely the case.
41-
As its name implies, this keyword enforces the instance to
42-
be valid against **only one of its subschemas**. Therefore, a JSON Schema
43-
implementation will exhaustively evaluate every subschema to make sure the rest
44-
fails, potentially introducing unnecessary computational overhead.
40+
semantics, which is rarely the case. As its name implies, this keyword
41+
enforces the instance to be valid against **only one of its subschemas**.
42+
Therefore, a JSON Schema implementation will exhaustively evaluate every
43+
subschema to make sure the rest fails, potentially introducing unnecessary
44+
computational overhead.
4545

4646
{{</common-pitfall>}}
4747

4848
This keyword is equivalent to the following complex boolean construct that
49-
combines the `||`, `&&`, and `!` operators found in most programming languages:
49+
combines the `||`, `&&`, and `!` operators found in most programming
50+
languages:
5051

5152
```c
5253
bool valid = (A && !B && !C) || (!A && B && !C) || (!A && !B && C);

content/2019-09/applicator/patternProperties.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ definitions. Information about the properties that this keyword was evaluated
4848
for is reported using annotations.
4949

5050
{{<common-pitfall>}} This keyword is evaluated independently of the
51-
[`properties`]({{< ref "2020-12/applicator/properties" >}}) keyword. If an
51+
[`properties`]({{< ref "2019-09/applicator/properties" >}}) keyword. If an
5252
object property is described by both keywords, then both subschemas must
5353
successfully validate against the given property for validation to succeed.
5454
Furthermore, an instance property may match more than one regular expression

0 commit comments

Comments
 (0)