A resolved value is validated against the parameter schema, null included
The rule
- A resolved value MUST be validated against the parameter's schema as JSON Schema validates an instance, a
nullincluded. - A
nulltherefore MUST failtypeunless the type admitsnull, and MUST failenumunless the enumeration listsnull. - Constraints that apply only to strings, numbers, arrays or objects do not apply to a
null, as in JSON Schema. - Every resolved value MUST be validated, and any violation MUST fail the node execution with a validation error.
- The error MUST name every parameter whose value failed and, for each, every constraint that failed, in no defined order.
- For each value,
typeandenumMUST be checked first, and either one failing MUST end the check of that value there, so that it is the only constraint named for that parameter. - A parameter absent from the resolved parameter set has no value, and is not validated.
What it means
A resolved value is validated exactly as a JSON Schema validator would validate
it, and a null is no exception. null is a type of its own: it passes
"type": "string" no more than a number would, and it passes only a schema
whose type admits it, such as ["string", "null"]. A parameter that is meant
to accept "nothing chosen" says so in its schema.
What a null is spared is only what JSON Schema spares it: a minimum length, a
pattern or a format describe strings, so they have nothing to say about a
null. enum is different: a null passes it only where the enumeration
lists null.
Every value is checked, and a failure names all of them: each parameter whose
value failed, with each constraint it failed, in no particular order. An author sees
every problem at once, and the answer is the same in every language and whatever
order the parameters were declared in. Only type and enum cut a value's check
short, because the other constraints mean little for a value of the wrong type or
outside the list.
A parameter that nothing supplied at all is not validated here. It has no value, and CFG-9 has already decided whether that is allowed.
Example
{ "type": ["string", "null"], "enum": ["low", "high", null], "minLength": 3 }nullThe same null against { "type": "string" } fails the node with a type
violation.
Why
Fixtures
Test cases whose outcome this rule decides. A case compares absent, null and empty members exactly; the fixtures README defines each operation. Where a case and the rule disagree, the rule is right.
A null fails an enumeration that does not list it resolve-parameters
{ "given": { "parameters": { "x": { "schema": { "type": [ "string", "null" ], "enum": [ "a", "b" ] }, "connectable": true, "exposed": true, "configurable": true } }, "config": { "x": null } }, "expect": { "failed": { "error": "validation", "constraints": { "x": [ "enum" ] } } } }A null is not held to string-only constraints resolve-parameters
{ "given": { "parameters": { "x": { "schema": { "type": [ "string", "null" ], "minLength": 3, "pattern": "^[a-z]+$" }, "connectable": true, "exposed": true, "configurable": true } }, "config": { "x": null } }, "expect": { "resolved": { "x": null } } }An optional null is validated too resolve-parameters
Optional means the parameter may be absent, not that a null skips its type.
{ "given": { "parameters": { "x": { "schema": { "type": "string" }, "connectable": true, "exposed": true, "configurable": true } }, "config": { "x": null } }, "expect": { "failed": { "error": "validation", "constraints": { "x": [ "type" ] } } } }A null meets required, and passes where the type admits null resolve-parameters
{ "given": { "parameters": { "x": { "schema": { "type": [ "string", "null" ] }, "required": true, "connectable": true, "exposed": true, "configurable": true } }, "config": { "x": null } }, "expect": { "resolved": { "x": null } } }A null meets required, then fails a type that does not admit it resolve-parameters
{ "given": { "parameters": { "x": { "schema": { "type": "string" }, "required": true, "connectable": true, "exposed": true, "configurable": true } }, "config": { "x": null } }, "expect": { "failed": { "error": "validation", "constraints": { "x": [ "type" ] } } } }Every failing parameter and every failing constraint is named resolve-parameters
y fails
type, which ends its check, sominimumis not named for it.{ "given": { "parameters": { "x": { "schema": { "type": "string", "pattern": "^a", "minLength": 5, "maxLength": 1 }, "connectable": true, "exposed": true, "configurable": true }, "y": { "schema": { "type": "number", "minimum": 10 }, "connectable": true, "exposed": true, "configurable": true } }, "config": { "x": "bb", "y": "text" } }, "expect": { "failed": { "error": "validation", "constraints": { "x": [ "maxLength", "minLength", "pattern" ], "y": [ "type" ] } } } }