Add a schema group to a container node
Arguments
- x
A
SchemaDoc.- group
Schema group fragment using the same list syntax accepted by
schema_doc(), or a fragment produced byschema_group().- path
Path to the target container 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`.
Examples
schema <- schema_doc(list(check = list(kind = "list")))
schema
#> {
#> "check": {
#> "kind": "list"
#> }
#> }
schema <- schema_add_group(schema, schema_group(c("x", "y"), schema_check("number")))
schema
#> {
#> "check": {
#> "kind": "list"
#> },
#> "groups": [
#> {
#> "names": ["x", "y"],
#> "check": {
#> "kind": "number"
#> }
#> }
#> ]
#> }
schema_validate(schema, list(x = 1, y = 2), mode = "test")
#> [1] TRUE