Set a schema node keys rule
Arguments
- x
A
SchemaDoc.- path
Path to the target schema node. Use
$for the root node. Bare field segments such as$idimplicitly traverse containerfields. Use$fields$idto write the explicit field path. Backtick-quote field names that contain path operators, for example$`a$b`.- ...
Named
keysrule arguments passed through to the schema DSL.
Examples
schema <- schema_doc(list(check = list(kind = "list")))
schema
#> {
#> "check": {
#> "kind": "list"
#> }
#> }
schema_validate(schema, list(id = 1L), mode = "test")
#> [1] TRUE
schema <- schema_set_keys(schema, type = "named", must.include = "id")
schema
#> {
#> "check": {
#> "kind": "list"
#> },
#> "keys": {
#> "type": "named",
#> "must.include": "id"
#> }
#> }
schema_validate(schema, list(id = 1L), mode = "assert")