Skip to main content
Version: v0.0.3

Function: partitionWarnings()

partitionWarnings<W>(warnings, profile): NcpdpWarningPartition<W>

Split a parse's warnings against a profile's expected-warning union. A warning whose code is in the profile's expectedWarnings lands in expected; everything else lands in unexpected. Order within each bucket preserves the input order.

Type Parameters

W

W extends object

Parameters

warnings

readonly W[]

profile

NcpdpProfile

Returns

NcpdpWarningPartition<W>

Example

import { parseTelecom } from "@cosyte/ncpdp/telecom";
import { partitionWarnings, profiles } from "@cosyte/ncpdp/profiles";
const tx = parseTelecom(raw, { profile: profiles.pbm });
const { expected, unexpected } = partitionWarnings(tx.warnings, profiles.pbm);
if (unexpected.length > 0) flagForReview(unexpected);