Run the MobilityData Canonical GTFS Schedule Validator on a ZIP archive or a GTFS object and return its findings. The validator checks the official GTFS Schedule specification and produces additional best-practice notices.
Usage
validate_gtfs(
gtfs,
validator_jar = NULL,
output_dir = NULL,
quiet = FALSE,
download_validator = FALSE
)Arguments
- gtfs
Path to a local GTFS ZIP archive or a named list of GTFS tables, including a
wizardgtfsobject.- validator_jar
Optional path to a MobilityData validator CLI JAR. When
NULL, use the path inGTFS_VALIDATOR_JAR. The JAR must support--skip_validator_update.- output_dir
Optional directory in which to keep the validator's reports. It must not exist or must be empty. When
NULL, temporary files are removed after validation and no reports are saved.- quiet
Logical. If
FALSE(the default), print a summary of the findings. Set toTRUEto return the result without printing.- download_validator
Logical. If
TRUEand no JAR path is supplied, download the official validator to the user's cache if necessary and reuse it on subsequent calls. Requires internet access on the first download and the suggested packageopensslfor SHA-256 verification.
Value
A list with class gtfs_validation: notices, a data frame with
rule codes, severities, occurrence counts and sample details;
system_notices, a data frame of system errors; report and
system_errors, the parsed JSON reports; has_errors, TRUE or FALSE
when validation completed with recognized severities and without system
errors, otherwise NA; and
report_path, system_errors_path, html_path, and output_dir, which
are NULL when reports are not saved. The result is returned invisibly.
Details
Requires Java 17 or newer and the suggested package jsonlite. Supply a
MobilityData CLI JAR from https://github.com/MobilityData/gtfs-validator/releases
(version 8.0.1 or newer recommended), or explicitly set
download_validator = TRUE to download version 8.0.1. The cached download's
SHA-256 is checked against the published release checksum before each use.
The ZIP is passed directly to the validator without importing or repairing
it. An object is first exported with write_gtfs(); its report describes the
exported representation, not the original file or any previously repaired
data. No data are uploaded by this function. Results depend on the validator
version and its implemented rules; no errors found is not a certification.
The output directory must be empty to avoid overwriting existing reports or confusing a failed execution with a previous successful one.
Examples
# Requires Java 17 or newer, jsonlite and openssl, and initially internet:
if (FALSE) { # \dontrun{
result <- validate_gtfs(for_rail_gtfs, download_validator = TRUE)
result$notices
# Supply output_dir to keep the HTML and JSON reports:
result <- validate_gtfs(for_rail_gtfs, output_dir = "validation-report",
download_validator = TRUE)
} # }