Add a position schema to an unnamed container node
Arguments
- x
A
SchemaDoc.- index
1-based insertion index.
1inserts at the front andlength(positions) + 1appends.- value
Schema fragment using the same list syntax accepted by
schema_doc(), or a fragment produced by helpers such asschema_check().- path
Path to the target unnamed container node. Use
$for the root node.
Examples
schema <- schema_doc(list(
check = list(kind = "list"),
keys = list(type = "unnamed")
))
schema <- schema_add_position(schema, 1, schema_check("string"))
schema <- schema_add_position(schema, 2, schema_check("int"))
schema
#> {
#> "check": {
#> "kind": "list"
#> },
#> "keys": {
#> "type": "unnamed"
#> },
#> "positions": [
#> {
#> "check": {
#> "kind": "string"
#> }
#> },
#> {
#> "check": {
#> "kind": "int"
#> }
#> }
#> ]
#> }
schema_validate(schema, list("a", 1L), mode = "test")
#> [1] TRUE