'S7' Framework for Schema-Validated YAML Configuration

Provides a generic framework for working with YAML (YAML Ain't Markup Language) configuration files. Uses 'ajv' (Another JSON Schema Validator) via 'V8' to validate configurations against JSON Schema definitions. Configuration objects inherit from 'S7' classes and base lists, supporting downstream extension through custom classes and methods.


S7schema S7schema website

R-CMD-check

S7schema provides a generic way of working with yaml config files. The main functionality is captured in the S7schema() class that:

  1. Uses S7 for easy downstream use in other packages (e.g. new child classes and methods).
  2. Uses ‘ajv’ for validation of the config file given JSON schema.
  3. Inherits from list ensuring a seamless integration into existing code using the configuration entries.

Installation

# Install the latest released version from CRAN:
install.packages("S7schema")

# Install the development version from GitHub:
pak::pak("NovoNordisk-OpenSource/S7schema")

Usage

library(S7schema)

A new instance of an S7schema class can be initiated with:

config <- S7schema("path/to/my/config.yml", "path/to/my/schema.json")

Since config is a list it can be updated (here adding an “a” element):

config$a <- 2

And it can be validated again:

validate(config)

Which will now throw an error if a = 2 is an illegal entry according to the schema in "path/to/my/schema.json".

Learn more

  • vignette("S7schema") — Getting started
  • vignette("use-in-package") — Use S7schema in your package

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("S7schema")

0.1.2 by Aksel Thomsen, 2 months ago


https://novonordisk-opensource.github.io/S7schema/, https://github.com/NovoNordisk-OpenSource/S7schema


Report a bug at https://github.com/NovoNordisk-OpenSource/S7schema/issues


Browse source code at https://github.com/cran/S7schema


Authors: Aksel Thomsen [aut, cre] , Matthew Phelps [aut] , Novo Nordisk A/S [cph] , Evgeny Poberezkin [cph] (Author of included ajv , fast-deep-equal , and json-schema-traverse libraries) , Python Software Foundation [cph] (Copyright holder of Python argparse (included argparse library is a JavaScript port)) , Vladimir Zapparov [cph] (Author of included js-yaml library) , Vincent Le Goff [cph] (Author of included fast-uri library) , Vsevolod Strukchinsky [cph] (Author of included require-from-string library)


Documentation:   PDF Manual  


Apache License (>= 2) license


Imports cli, rlang, S7, tools, V8, yaml

Suggests jsonlite, knitr, purrr, rmarkdown, testthat, tibble, tidyr, withr


Imported by mighty.metadata.


See at CRAN