Skip to content

Check that a payload is a valid envelope

Source: R/read-envelope.R ยท Help: ?validate_envelope

validate_envelope() checks a payload against the rules of the envelope schema (envelope_schema()): each node is exactly one of an exception record, a cycle record or a truncation marker; identity fields are strings; a failure record carries all three of its fields with valid values; and the two markers carry nothing beyond their own fields. Fields the schema does not know are accepted, because a newer producer may add them.

Usage

validate_envelope(x, max_depth = 32L)

is_envelope(x, max_depth = 32L)

Arguments

x
An envelope: a JSON string, or a list as returned by condition_to_envelope() or jsonlite::parse_json().
max_depth
The deepest chain of nested records to accept.

Value

validate_envelope() returns x invisibly when it is valid and signals a dataexcept_envelope_error listing every problem otherwise. is_envelope() returns TRUE or FALSE.

Details

The check is structural and needs no JSON Schema validator. It is the check envelope_to_condition() applies before reading.

Examples

is_envelope('{"type": "ValueError", "module": "builtins", "message": "bad row"}')
is_envelope('{"type": "ValueError", "message": "bad row"}')

try(validate_envelope('{"truncated": true, "type": "ValueError"}'))