Learn R Programming

schemate (version 0.1.0)

schema_add_position: Add a position schema to an unnamed container node

Description

Add a position schema to an unnamed container node

Usage

schema_add_position(x, index, value, path = "$")

Value

A modified SchemaDoc.

Arguments

x

A SchemaDoc.

index

1-based insertion index. 1 inserts at the front and length(positions) + 1 appends.

value

Schema fragment using the same list syntax accepted by schema_doc(), or a fragment produced by helpers such as schema_check().

path

Path to the target unnamed container node. Use $ for the root node.

Examples

Run this code
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

schema_validate(schema, list("a", 1L), mode = "test")

Run the code above in your browser using DataLab