import type { Field, Nodes } from "@rethinkhealth/hl7v2-ast"; export type ValidationErrorCode = "MISSING" | "EMPTY" | "UNEXPECTED_CONTENT" | "CARDINALITY_UNDERFLOW" | "CARDINALITY_OVERFLOW" | "LENGTH_UNDERFLOW" | "LENGTH_OVERFLOW" | "VALUE_NOT_IN_TABLE"; export interface ValidationError { code: ValidationErrorCode; message: string; expected?: string | number | Array; actual?: string | number | Array; } export interface ValidationSuccess { ok: true; } export interface ValidationFailure { ok: false; error: ValidationError; } export type ValidationResult = ValidationSuccess | ValidationFailure; export declare const OptionalityCode: { /** * Backward Compatible * * There are no implementation requirements. The “B” usage indicates that the * element is retained for backwards compatibility of the element. Another * usage indicator may be assigned in a derived profile. */ readonly BackwardCompatible: "B"; /** * Undeclared / Conditional. * * There are no implementation requirements. The “C” usage designation is a * placeholder indicating that the usage for this element has not yet been * specified. */ readonly Conditional: "C"; /** * Not Supported. * * There are no implementation requirements. The application must not value an * element with an “X” usage designation. */ readonly NotSupported: "X"; /** * Optional * * There are no implementation requirements. The “O” usage designation is a * placeholder indicating that the usage for this element has not yet been * specified. */ readonly Optional: "O"; /** * Required */ readonly Required: "R"; /** * Required, but may be empty. * * The use of the RE usage code is qualified with the “if data is known” * clause. The sender must interpret the clause as “the capability must always * be supported, and data must always be sent if known”. To clarify, the * sender does not determine whether the data should be sent; to be conformant * to the rule, the data must be sent. There is a misconception where the RE * usage is interpreted as “the capability must always be supported, and data * may or may not be sent even when known based on a condition external to the * profile specification”. * * The receiving application must process in a meaningful way the information * conveyed by an element with an “RE” usage designation. * The receiving application must process the message if the element is omitted * (that is, an exception must not be raised because the element is missing). A * receiving application must not raise an exception due to the presence of a * required element. */ readonly RequiredOrEmpty: "RE"; /** * Withdrawn * * The element has been withdrawn from the standard. There are no * implementation requirements. The application must not value an element with * a "W" usage designation. */ readonly Withdrawn: "W"; }; export type OptionalityCode = (typeof OptionalityCode)[keyof typeof OptionalityCode]; /** * Checks if a field satisfies the cardinality constraint. */ export declare function checkCardinality(node: Field | undefined, min: number, max: number | "*"): ValidationResult; /** * Checks if a node satisfies the length constraint. */ export declare function checkLength(node: Nodes | undefined, max: number, min?: number): ValidationResult; /** * Checks if a node satisfies the optionality constraint. */ export declare function checkOptionality(node: Nodes | undefined, optionality: OptionalityCode | string): ValidationResult; //# sourceMappingURL=constraints.d.ts.map