Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

X12Parser API

Josh Johnson edited this page Apr 19, 2016 · 2 revisions

API Surface

Constructor

When constructing an instance of X12Parser, you must specify if parsing should be strict or not. When strict parsing is enabled, a ParserError will be thrown if there are any syntax issues or X12 standards issues (such as a control number mismatch). Otherwise, these errors will simply be tracked in the diagnostics property of the parser instance.

constructor(private _strict: boolean) { }

Instance Properties

Property Type Notes
diagnostics X12Diagnostic[] A collection of diagnostics accumulated while parsing the raw X12 data.

Instance Methods

Method Returns Notes
parseX12(edi: string) X12Interchange The input X12 data must contain a valid envelope (ISA/IEA, GS/GE segments).

Example

import { X12Parser } from 'x12/core';

let rawEDI = '...';

let parser = new X12Parser(false);
let interchange = parser.parseX12(rawEDI);

if (parser.diagnostics.length > 0) {
    // do something about the syntax errors
}

API Documentation

Clone this wiki locally