Checks the types of fields, represented by columns, inside a GTFS object element.

check_fields_types(x, file, fields, types)

assert_fields_types(x, file, fields, types)

Arguments

x

A GTFS object.

file

A string. The element, that represents a GTFS text file, whose fields' types should be checked.

fields

A character vector. The fields to have their types checked.

types

A character vector, with the same length of fields. The types that each field must inherit from.

Value

check_fields_types returns TRUE if the check is successful, and FALSE otherwise.
assert_fields_types returns x invisibly if the check is successful, and throws an error otherwise.

See also

Other checking functions: check_fields_exist(), check_files_exist()

Examples

gtfs_path <- system.file("extdata/ggl_gtfs.zip", package = "gtfsio")
gtfs <- import_gtfs(gtfs_path)

check_fields_types(
  gtfs,
  "calendar",
  fields = c("monday", "tuesday"),
  types = rep("integer", 2)
)
#> [1] TRUE

check_fields_types(
  gtfs,
  "calendar",
  fields = c("monday", "tuesday"),
  types = c("integer", "character")
)
#> [1] FALSE