Skip to contents

Compares a tibble with the fields in telem_fields() and reports everything wrong at once. Every telem_create_*() calls this before building a request, so this is only needed directly to check data ahead of time — it performs no request and needs no credentials.

Usage

telem_validate(data, resource, action = c("create", "update"))

Arguments

data

A data frame, one row per record.

resource

Character. Which endpoint the data is destined for. See telem_fields().

action

Character. "create" checks the data as a new record, which is the default. "update" checks it as a change to an existing one: the required fields become optional, because an update sends only what it is changing, and an id naming the record is required instead. Fields that must be present stay present, and types, limits and accepted values are enforced the same either way.

Value

data as a tibble, invisibly, with any datetime columns formatted for the wire. Aborts if anything is wrong, listing every problem.

Examples

telem_validate(
  tibble::tibble(serial_number = "A-001", state = "In-Hand"),
  "devices"
)