Validates the GTFS object against GTFS specifications and raises warnings if required files/fields are not found. This function is called in read_gtfs.

validate_gtfs(gtfs_obj, files = NULL, quiet = TRUE, warnings = TRUE)



A GTFS object


A character vector containing the text files to be validated against the GTFS specification (without the .txt extension). If NULL (the default) the provided GTFS is validated against all possible GTFS text files.


Whether to hide log messages (defaults to TRUE).


Whether to display warning messages (defaults to TRUE).


A tidygtfs with a validation_result attribute. This attribute is a tibble containing the validation summary of all possible fields from the specified files.


GTFS object's files and fields are validated against the GTFS specifications as documented in Google's Static GTFS Reference:

  • GTFS feeds are considered valid if they include all required files and fields. If a required file/field is missing the function (optionally) raises a warning.

  • Optional files/fields are listed in the reference above but are not required, thus no warning is raised if they are missing.

  • Extra files/fields are those who are not listed in the reference above (either because they refer to a specific GTFS extension or due to any other reason).

Note that some files (calendar.txt, calendar_dates.txt and feed_info.txt) are conditionally required. This means that:

  • calendar.txt is initially set as a required file. If it's not present, however, it becomes optional and calendar_dates.txt (originally set as optional) becomes required.

  • feed_info.txt is initially set as an optional file. If translations.txt is present, however, it becomes required.


local_gtfs_path <- system.file("extdata", "", package = "tidytransit")
gtfs <- read_gtfs(local_gtfs_path)
attr(gtfs, "validation_result")
#> # A tibble: 136 × 8
#>    file   file_spec file_provided_status field       field_spec field_provided_…
#>    <chr>  <chr>     <lgl>                <chr>       <chr>      <lgl>           
#>  1 agency req       TRUE                 agency_id   opt        TRUE            
#>  2 agency req       TRUE                 agency_name req        TRUE            
#>  3 agency req       TRUE                 agency_url  req        TRUE            
#>  4 agency req       TRUE                 agency_tim… req        TRUE            
#>  5 agency req       TRUE                 agency_lang opt        TRUE            
#>  6 agency req       TRUE                 agency_pho… opt        TRUE            
#>  7 agency req       TRUE                 agency_far… opt        FALSE           
#>  8 agency req       TRUE                 agency_ema… opt        FALSE           
#>  9 stops  req       TRUE                 stop_id     req        TRUE            
#> 10 stops  req       TRUE                 stop_code   opt        TRUE            
#> # … with 126 more rows, and 2 more variables: validation_status <chr>,
#> #   validation_details <chr>

gtfs$shapes <- NULL
validation_result <- validate_gtfs(gtfs)

# should raise a warning
gtfs$stop_times <- NULL
validation_result <- validate_gtfs(gtfs)
#> Warning: Invalid feed. Missing required file(s): stop_times.txt