sanitize

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sanitize turns an accepted X12 set into what the agent may see: the typed body and the notes (control M1, the white list).

Input: an x12.Set that Parse accepted and the partner id from the envelope. Output: a Result with the JSON body, the business reference and the notes.

One rule: an element reaches the body only if it is on the list below and passes the format of its place. A listed element that fails its format is replaced by its note reference ("$note_N", reason "format"). The free text elements (PID05, MSG01, REF03, N1-02, N2, PER, NTE02, MTX) never enter the body: each one becomes a note (reason "free_text"). Elements that are on neither list (N3, N4, DTM, PER01, PO105, ...) are dropped without a note.

Notes are numbered in document order. Each note carries the taint label of the partner and a random canary (16 hex characters) that the quarantined reader uses to notice a model that repeats its input.

Index

Constants

View Source
const (
	ReasonFreeText = "free_text"
	ReasonFormat   = "format"
)

Reasons a piece of text is a note.

Variables

This section is empty.

Functions

This section is empty.

Types

type Note

type Note struct {
	Ref         string // $note_1, $note_2, ... in document order
	SegmentPath string // for example PO1[2]/PID[1]/PID05
	Reason      string // free_text or format
	Text        string
	TaintLabel  string // partner:<partner_id>
	Canary      string
}

Note is a piece of partner text kept out of the body.

type Result

type Result struct {
	BusinessRef string
	// BKRef is the raw BEG03 (850) or BIG02 (810) without spaces at the edges: the
	// value the idempotency key is built from. Internal only, never shown to the agent.
	BKRef string
	Body  []byte
	Notes []Note
}

Result is what Build returns for one set. BusinessRef is the value the agent sees as the business reference (a note reference if BEG03 or BIG02 failed its format); Notes is empty for a 997.

func Build

func Build(set *x12.Set, partnerID string) (Result, error)

Build makes the body and the notes of an accepted set. partnerID is the sender (ISA05:ISA06). It fails for a set type it does not know.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL