Replace a schema node
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`.- value
Replacement schema fragment using the same list syntax accepted by
schema_doc(), or a fragment produced by helpers such asschema_check()orschema_ref().
Examples
schema <- schema_doc(list(
check = list(kind = "list"),
fields = list(id = schema_check("int"))
))
schema <- schema_replace(schema, "$id", schema_check("int", lower = 1))
schema
#> {
#> "check": {
#> "kind": "list"
#> },
#> "fields": {
#> "id": {
#> "check": {
#> "kind": "int",
#> "lower": 1
#> }
#> }
#> }
#> }
schema_validate(schema, list(id = 1L), mode = "test")
#> [1] TRUE