# A schema as `S7_to_JSONSchema()` emits it: standard keywords carry the
# bounds, `x-rtemis` carries the leaf type.
schema <- list(
title = "Demo",
properties = list(
k = list(
type = "integer",
minimum = 1L,
maximum = 10L,
description = "Number of components.",
`x-rtemis` = list(type = "integer")
)
)
)
Demo <- JSONSchema_to_S7(schema, defaults = list(k = 2L))
Demo()@k
Demo(k = 5L)@k
# The reconstructed class enforces the schema's bounds.
tryCatch(Demo(k = 99L), error = conditionMessage)
Run the code above in your browser using DataLab