Skip to contents

Validates a PEcAn events JSON file (single-site object or an array of site objects) against the bundled JSON Schema using the AJV engine.

Usage

validate_events_json(
  events_json,
  schema_version = "0.1.1",
  verbose = TRUE,
  max_errs = 50
)

Arguments

events_json

character. Path to the JSON file to validate.

schema_version

character. Version of the PEcAn events schema to validate against.

verbose

logical. When `TRUE`, include detailed AJV messages on error.

max_errs

integer. Print only this many validation errors. To see the rest, use the `errors` attribute of the return value.

Value

Logical TRUE if valid. If invalid, FALSE with an attribute "errors" containing a dataframe of reported problems. NA if validator unavailable.

Details

- Logs an error and returns FALSE if the JSON file does not exist or does not conform to the schema. - Logs a warning and returns TRUE if the optional package `jsonvalidate` is not installed, so calling code can proceed without a hard dependency.

Author

David LeBauer

Examples

# validate_events_json(system.file("events_fixtures/events_site1.json",
#                                package = "PEcAn.data.land"))