Skip to main content
Version: v0.0.3

Function: validateFormat()

validateFormat(format, bytes): Promise<Verdict>

Run the format's validation surface and return a value-free Verdict. For the Postel's-Law lenient parsers, a parseable input is valid: recovered deviations are non-fatal warnings the library surfaces, never a stricter verdict the CLI invents. FHIR additionally runs validateResource and is invalid on any error/fatal-severity issue.

Parameters

format

CosyteFormat

A format for which supportsOp(format, "validate") is true.

bytes

Uint8Array

The input bytes.

Returns

Promise<Verdict>

The value-free verdict (findings + validity).

Throws

CLI_PARSER_UNAVAILABLE if the optional parser is absent; an unparseable input propagates as the wrapped parser's throw for the command to map to a data error (65).

Example

import { validateFormat } from "@cosyte/cli";

const bytes = new TextEncoder().encode('{"resourceType":"Patient","gender":"male"}');
(await validateFormat("fhir", bytes)).valid; // => true