toml_validate | R Documentation |
Validates a TOML file or character vector using the external Taplo CLI, optionally against a JSON Schema (Draft 4).
toml_validate(input, from_file = TRUE, schema = NULL, top_errors_only = TRUE)
input |
If |
from_file |
Whether |
schema |
URL to a JSON Schema (Draft 4) file to validate |
top_errors_only |
Whether to reduce the output to the top error message of each of TOML CLI's error classes. If |
The highest supported JSON Schema specification is Draft 4. This is a limitation of the underlying tool Taplo.
Taplo allows to define the schema to be used directly in the TOML file using the schema
header directive. Note that the schema
argument has precendence unless set to
NULL
(the default).
If the validation is successful, input
invisibly. Otherwise an error is thrown.
Although there are two noteworthy attempts at introducing a native validation format for TOML, TOLS and TOML Schema, neither of them has been officially adopted yet. As it appears, it could take several more years to decades until such thing happens, if ever.
In the meantime, we can use the JSON Schema format as an alternative thanks to an awesome implementation by the Taplo CLI, which itself is written in the Rust programming language and available as a single-binary program for all common platforms.
Other TOML functions:
toml_read()
try(
pal::toml_validate(input = "key = tru",
from_file = FALSE)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.