{"id":22943945,"url":"https://github.com/moov-io/x12","last_synced_at":"2025-07-03T13:35:31.350Z","repository":{"id":151234798,"uuid":"613978039","full_name":"moov-io/x12","owner":"moov-io","description":"ASC X12 standards reader/writer","archived":false,"fork":false,"pushed_at":"2025-03-11T20:50:10.000Z","size":400,"stargazers_count":9,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T12:03:17.724Z","etag":null,"topics":["837d","837p","asc","edi","x12"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moov-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-14T16:39:48.000Z","updated_at":"2025-03-25T05:58:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"9367026e-8b8d-4eed-9975-bb3f7641e3f9","html_url":"https://github.com/moov-io/x12","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/moov-io/x12","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fx12","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fx12/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fx12/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fx12/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moov-io","download_url":"https://codeload.github.com/moov-io/x12/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moov-io%2Fx12/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263335807,"owners_count":23450934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["837d","837p","asc","edi","x12"],"created_at":"2024-12-14T14:14:56.088Z","updated_at":"2025-07-03T13:35:31.336Z","avatar_url":"https://github.com/moov-io.png","language":"Go","funding_links":[],"categories":["Libraries"],"sub_categories":["Golang"],"readme":"[![Moov Banner Logo](https://user-images.githubusercontent.com/20115216/104214617-885b3c80-53ec-11eb-8ce0-9fc745fb5bfc.png)](https://github.com/moov-io)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/moov-io/x12\"\u003eProject Documentation\u003c/a\u003e\n  ·\n  \u003ca href=\"https://slack.moov.io/\"\u003eCommunity\u003c/a\u003e\n  ·\n  \u003ca href=\"https://moov.io/blog/\"\u003eBlog\u003c/a\u003e\n  \u003cbr\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n[![GoDoc](https://godoc.org/github.com/moov-io/x12?status.svg)](https://godoc.org/github.com/moov-io/x12)\n[![Build Status](https://github.com/moov-io/x12/workflows/Go/badge.svg)](https://github.com/moov-io/x12/actions)\n[![Coverage Status](https://codecov.io/gh/moov-io/x12/branch/master/graph/badge.svg)](https://codecov.io/gh/moov-io/x12)\n[![Go Report Card](https://goreportcard.com/badge/github.com/moov-io/x12)](https://goreportcard.com/report/github.com/moov-io/x12)\n[![Repo Size](https://img.shields.io/github/languages/code-size/moov-io/x12?label=project%20size)](https://github.com/moov-io/x12)\n[![Apache 2 License](https://img.shields.io/badge/license-Apache2-blue.svg)](https://raw.githubusercontent.com/moov-io/x12/master/LICENSE)\n[![Slack Channel](https://slack.moov.io/badge.svg?bg=e01563\u0026fgColor=fffff)](https://slack.moov.io/)\n[![Docker Pulls](https://img.shields.io/docker/pulls/moov/x12)](https://hub.docker.com/r/moov/x12)\n[![GitHub Stars](https://img.shields.io/github/stars/moov-io/x12)](https://github.com/moov-io/x12)\n[![Twitter](https://img.shields.io/twitter/follow/moov?style=social)](https://twitter.com/moov?lang=en)\n\n# moov-io/x12\n\nmoov-io/x12 is a Go library for parsing and generating Accredited Standards Committee X12 (ASC X12) documents. The goal is to support Electronic data interchange (EDI) Context Inspired Component Architecture (CICA) standards which support health care, insurance, transportation, finance, government, supply chains and many other industries.\n\n## Project status\n\nThe x12 is actively being developed for use in production systems. Please star the project if you are interested in its progress. If you need other ASC X12 formats, find bugs, have comments, or suggstions we would appreciate an issue or pull request. Thanks!\n\n## Go library\n\nThis project uses [Go Modules](https://go.dev/blog/using-go-modules) and Go v1.19 or newer. See [Golang's install instructions](https://golang.org/doc/install) for help in setting up Go. You can download the source code and we offer [tagged and released versions](https://github.com/moov-io/iso8583/releases/latest) as well. We highly recommend you use a tagged release for production.\n\n### Installation\n\n```\ngo get github.com/moov-io/x12\n```\n\n### Goal of the moov-io/x12 project\nX12 defines and maintains transaction sets that establish the data content exchanged for specific business purposes.\nTransaction sets are identified by a numeric identifier and a name.\nEach transaction set is maintained by a subcommittee operating within X12’s Accredited Standards Committee.\n\nMoov-io/x12 project will support some kinds of x12 transaction sets\n* X12F - Finance / 820 Payment Order \u0026 Remittance Advice\n* X12C - Communications \u0026 Controls / 999 Implementation Acknowledgment\n* X12N - Insurance / 837 Health Care Claim\n* X12N - Insurance / 835 Health Care Claim Payment \u0026 Advice\n\nTo support these transaction sets, x12 project used following data unit\n* Interchange\n  * Interchange includes control header(ISA), control trailer(IEA), functional groups. i.e., segments and groups\n* Group\n  * Functional group includes group header(GS), group trailer(GE), transaction sets. i.e., segments and transaction sets\n* Transaction Set\n  * Transaction set includes transaction set header(SA), transaction set trailer(SE), groups, and segments. i.e., segments and loops\n* Loop\n  * Loop includes composite loops and segments. i.e., segments and loops\n* Segment\n  * Segment includes data fields\n\nAny x12 transaction set will describe as structured data units with leveled order\nAbove data hierarchy, we can see that loop has nested sub-loop\nOf course each x12 transaction will have different structured data units (loop structure and segments of transaction set)\n\nHow to specify structured data units according to x12 transaction type?\nHow to support specification of x12 transaction with above general data units?\n\nMoov-io/x12 has rule feature to fix above problems.\nEach interchange will perform validation check based on specified rule\n\n### Define your rule\n\nCurrently, we support following rules for :\n\n* [4010 810](./rules/rule_4010_810/rule.go) - ASC X12F 4010 810\n* [4010 820](./rules/rule_4010_820/rule.go) - ASC X12F 4010 820 (004010X061A1)\n* [4010 835](./rules/rule_4010_835/rule.go) - ASC X12F 4010 825 (004010X091A1)\n* [4010 837I](./rules/rule_5010_837I/rule.go) - ASC X12N 4010 837I (004010X096A1)\n* [5010 835](./rules/rule_5010_835/rule.go) - ASC X12N 5010 835 (005010X221A1)\n* [5010 837d](./rules/rule_5010_837d/rule.go) - ASC X12N 5010 837 (005010X224A2)\n* [5010 837p](./rules/rule_5010_8837p/rule.go) - ASC X12N 5010 837 (005010X222A1)\n* [STP 820](./rules/rule_stp_820/rule.go) - ASC X12F STP 820 (004010STP820)\n\nWe can specify rule using some kinds of rule struts.\n\n#### InterchangeRule\n```\ntype InterchangeRule struct {\n\tName  string\n\tISA   SegmentRule\n\tIEA   SegmentRule\n\tGroup GroupRule\n}\n```\nInterchange rule defined details of control header.\n\n#### GroupRule\n```\ntype GroupRule struct {\n\tGS    SegmentRule\n\tGE    SegmentRule\n\tTrans TransactionRule\n}\n```\nGroup rule defined details of group header.\n\n#### TransactionRule\n```\ntype TransactionRule struct {\n\tST       SegmentRule\n\tSE       SegmentRule\n\tLoops    LoopSetRule\n\tSegments SegmentSetRule\n}\n```\nTransaction rule defined details of transaction set.\nLoops is ordered nested loop list.\norder is index of rule map.\n\n#### LoopSetRule\n```\ntype LoopSetRule map[int]LoopRule\n\ntype LoopRule struct {\n\tSegments    SegmentSetRule\n\tMask        string\n\tRepeatCount int\n\tName        string\n\tComposite   LoopSetRule\n}\n```\nLoop rule defined details of loop.\nMask is to specify loop's ability such as required, optional, non-used.\nIf the mask option is omitted, will deal as required.\nRepeatCount is to specify how many times repeat the loop\nIf the RepeatCount option is omitted, will deal as RepeatCount=1.\nComposite is ordered nested sub loops.\n\n#### SegmentSetRule\n```\ntype SegmentSetRule map[int]SegmentRule\n\ntype SegmentRule struct {\n\tElements    ElementSetRule\n\tMask        string\n\tRepeatCount int\n\tName        string\n\tDescription string\n}\n```\nMask and repeat count are same as loop's mask and repeat count\nElements is ordered fields\n\n#### SegmentSetRule\n```\ntype ElementSetRule map[string]ElementRule\n\ntype ElementRule struct {\n\tMask         string\n\tName         string\n\tAcceptValues []string\n\tComposite    ElementSetRule\n}\n```\nMask and repeat count are same as loop's mask and repeat count.\nComposite is ordered nested fields.\nAccept values is to specify available values that can use the field.\n\nElement's mask is a bit different from segment and loop.\nEach segment has a real struct such as IEA, ISA, GS, etc.\nField of segment is omitted field or required field (check out with json, xml tag).\nIf the mask option of element rule is omitted, will use original field's property (omitted field or required field).\n\n#### Rule example\n```\n\nimport \"github.com/moov-io/x12/pkg/rules\"\n\nvar InterchangeRule = rules.InterchangeRule{\n\tName: \"EPN STP 820\",\n\tISA: rules.SegmentRule{\n\t\tName:        \"ISA\",\n\t\tDescription: \"INTERCHANGE CONTROL HEADER\",\n\t\tMask:        rules.MASK_REQUIRED,\n\t\tElements: rules.ElementSetRule{\n\t\t\t\"01\": {AcceptValues: []string{\"00\"}},\n\t\t\t\"03\": {AcceptValues: []string{\"00\"}},\n\t\t\t\"05\": {AcceptValues: []string{\"01\", \"14\", \"17\", \"30\"}},\n\t\t\t\"07\": {AcceptValues: []string{\"01\", \"14\", \"17\", \"30\"}},\n\t\t\t\"11\": {AcceptValues: []string{\"U\"}},\n\t\t\t\"12\": {AcceptValues: []string{\"00401\"}},\n\t\t\t\"14\": {AcceptValues: []string{\"0\"}},\n\t\t\t\"15\": {AcceptValues: []string{\"P\"}},\n\t\t\t\"16\": {AcceptValues: []string{\"~\"}},\n\t\t},\n\t},\n\tIEA: rules.SegmentRule{\n\t\tName:        \"IEA\",\n\t\tDescription: \"INTERCHANGE CONTROL TRAILER\",\n\t\tMask:        rules.MASK_REQUIRED,\n\t\tElements:    rules.ElementSetRule{},\n\t},\n\tGroup: rules.GroupRule{\n\t\tGS: rules.SegmentRule{\n\t\t\tName:        \"GS\",\n\t\t\tDescription: \"FUNCTIONAL GROUP HEADER\",\n\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\"01\": {AcceptValues: []string{\"RA\"}},\n\t\t\t\t\"07\": {AcceptValues: []string{\"X\"}},\n\t\t\t\t\"08\": {AcceptValues: []string{\"004010STP820\"}},\n\t\t\t},\n\t\t},\n\t\tGE: rules.SegmentRule{\n\t\t\tName:        \"GE\",\n\t\t\tDescription: \"FUNCTIONAL GROUP TRAILER\",\n\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\tElements:    rules.ElementSetRule{},\n\t\t},\n\t\tTrans: rules.TransactionRule{\n\t\t\tST: rules.SegmentRule{\n\t\t\t\tName:        \"ST\",\n\t\t\t\tDescription: \"TRANSACTION SET HEADER\",\n\t\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\"01\": {AcceptValues: []string{\"820\"}},\n\t\t\t\t\t\"02\": {Mask: rules.MASK_REQUIRED},\n\t\t\t\t\t\"03\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t},\n\t\t\t},\n\t\t\tSegments: rules.SegmentSetRule{\n\t\t\t\t0: rules.SegmentRule{\n\t\t\t\t\tName:        \"BPR\",\n\t\t\t\t\tDescription: \"Beginning Segment for Payment Order/Remittance Advice\",\n\t\t\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\"01\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"C\"}},\n\t\t\t\t\t\t\"02\": {Mask: rules.MASK_REQUIRED},\n\t\t\t\t\t\t\"03\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"C\"}},\n\t\t\t\t\t\t\"04\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"ACH\"}},\n\t\t\t\t\t\t\"05\": {Mask: rules.MASK_OPTIONAL, AcceptValues: []string{\"CTX\"}},\n\t\t\t\t\t\t\"06\": {Mask: rules.MASK_OPTIONAL, AcceptValues: []string{\"01\"}},\n\t\t\t\t\t\t\"07\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"08\": {Mask: rules.MASK_OPTIONAL, AcceptValues: []string{\"DA\"}},\n\t\t\t\t\t\t\"09\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"10\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"11\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"12\": {Mask: rules.MASK_OPTIONAL, AcceptValues: []string{\"01\"}},\n\t\t\t\t\t\t\"13\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"14\": {Mask: rules.MASK_OPTIONAL, AcceptValues: []string{\"DA\"}},\n\t\t\t\t\t\t\"15\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"16\": {Mask: rules.MASK_REQUIRED},\n\t\t\t\t\t\t\"17\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"18\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"19\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"20\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"21\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t1: rules.SegmentRule{\n\t\t\t\t\tName:        \"TRN\",\n\t\t\t\t\tDescription: \"Trace\",\n\t\t\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\"01\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"1\"}},\n\t\t\t\t\t\t\"02\": {Mask: rules.MASK_REQUIRED},\n\t\t\t\t\t\t\"03\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"04\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t2: rules.SegmentRule{\n\t\t\t\t\tName:        \"NM1\",\n\t\t\t\t\tDescription: \"Originator Name Identification\",\n\t\t\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\"01\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"PR\"}},\n\t\t\t\t\t\t\"02\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"03\": {Mask: rules.MASK_OPTIONAL, AcceptValues: []string{\"91\"}},\n\t\t\t\t\t\t\"04\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"05\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"06\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"07\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"08\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"09\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t3: rules.SegmentRule{\n\t\t\t\t\tName:        \"NM1\",\n\t\t\t\t\tDescription: \"Receiver Name Identification\",\n\t\t\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\"01\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"PE\"}},\n\t\t\t\t\t\t\"02\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\"03\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"04\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"05\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"06\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"07\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"08\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\"09\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tSE: rules.SegmentRule{\n\t\t\t\tName:        \"SE\",\n\t\t\t\tDescription: \"TRANSACTION SET TRAILER\",\n\t\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\t\tElements:    rules.ElementSetRule{},\n\t\t\t},\n\t\t\tLoops: map[int]rules.LoopRule{\n\t\t\t\t0: {\n\t\t\t\t\tSegments: rules.SegmentSetRule{\n\t\t\t\t\t\t0: rules.SegmentRule{\n\t\t\t\t\t\t\tName:        \"ENT\",\n\t\t\t\t\t\t\tDescription: \"Entity\",\n\t\t\t\t\t\t\tMask:        rules.MASK_OPTIONAL,\n\t\t\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\t\t\"01\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\t\t\"02\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\t\t\"03\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\t\t\"04\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t1: rules.SegmentRule{\n\t\t\t\t\t\t\tName:        \"RMR\",\n\t\t\t\t\t\t\tDescription: \"Remittance Advice Accounts Receivable Open Item Reference\",\n\t\t\t\t\t\t\tMask:        rules.MASK_REQUIRED,\n\t\t\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\t\t\"01\": {Mask: rules.MASK_OPTIONAL, AcceptValues: []string{\"IV\", \"PO\", \"R7\"}},\n\t\t\t\t\t\t\t\t\"02\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\t\t\"03\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\t\t\"04\": {Mask: rules.MASK_REQUIRED},\n\t\t\t\t\t\t\t\t\"05\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\t\t\"06\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t2: rules.SegmentRule{\n\t\t\t\t\t\t\tName:        \"REF\",\n\t\t\t\t\t\t\tDescription: \"Reference Identification\",\n\t\t\t\t\t\t\tMask:        rules.MASK_OPTIONAL,\n\t\t\t\t\t\t\tRepeatCount: rules.GREATER_THAN_ONE,\n\t\t\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\t\t\"01\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"BM\", \"PO\", \"R7\", \"VV\"}},\n\t\t\t\t\t\t\t\t\"02\": {Mask: rules.MASK_REQUIRED},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t3: rules.SegmentRule{\n\t\t\t\t\t\t\tName:        \"DTM\",\n\t\t\t\t\t\t\tDescription: \"INDIVIDUAL COVERAGE PERIOD\",\n\t\t\t\t\t\t\tMask:        rules.MASK_OPTIONAL,\n\t\t\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\t\t\"01\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"003\", \"004\", \"092\"}},\n\t\t\t\t\t\t\t\t\"02\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\t\t\"03\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\t\t\"04\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\t\t\"05\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\t\t\"06\": {Mask: rules.MASK_NOTUSED},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t4: rules.SegmentRule{\n\t\t\t\t\t\t\tName:        \"ADX\",\n\t\t\t\t\t\t\tDescription: \"Adjustment\",\n\t\t\t\t\t\t\tMask:        rules.MASK_OPTIONAL,\n\t\t\t\t\t\t\tElements: rules.ElementSetRule{\n\t\t\t\t\t\t\t\t\"01\": {Mask: rules.MASK_REQUIRED},\n\t\t\t\t\t\t\t\t\"02\": {Mask: rules.MASK_REQUIRED, AcceptValues: []string{\"01\", \"03\", \"04\", \"05\", \"06\", \"07\", \"11\", \"12\", \"59\", \"75\", \"81\", \"CM\"}},\n\t\t\t\t\t\t\t\t\"03\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\t\t\"04\": {Mask: rules.MASK_OPTIONAL},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tMask:        rules.MASK_OPTIONAL,\n\t\t\t\t\tName:        \"Detail\",\n\t\t\t\t\tRepeatCount: rules.GREATER_THAN_ONE,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n}\n```\nIn above rule, transaction set should have ST, BPR, TRN, NM1, NM1, SE, and can have rules\n\n## Usage\n\nUser should create interchange, group, transaction, segments.\n```\n\tisa := segments.ISA{\n\t\tAuthorizationQualifier:    \"00\",\n\t\tAuthorizationInformation:  \" \",\n\t\tSecurityQualifier:         \"00\",\n\t\tSecurityInformation:       \" \",\n\t\tSenderQualifier:           \"30\",\n\t\tSenderId:                  \"227777777 \",\n\t\tReceiverQualifier:         \"14\",\n\t\tReceiverId:                \"577777777 \",\n\t\tDate:                      \"120530\",\n\t\tTime:                      \"1144\",\n\t\tStandardsId:               \"U\",\n\t\tVersion:                   \"00401\",\n\t\tInterchangeControlNumber:  \"000000001\",\n\t\tAcknowledgmentRequested:   \"0\",\n\t\tTestIndicator:             \"P\",\n\t\tComponentElementSeparator: \"~\",\n\t}\n\n\tiea := segments.IEA{}\n\tiea.SetFieldByIndex(\"01\", \"1\")\n\tiea.SetFieldByIndex(\"02\", \"000000001\")\n\n\tgs := segments.GS{}\n\tgs.SetFieldByIndex(\"01\", \"RA\")\n\tgs.SetFieldByIndex(\"02\", \"227777777\")\n\tgs.SetFieldByIndex(\"03\", \"577777777\")\n\tgs.SetFieldByIndex(\"04\", \"20120530\")\n\tgs.SetFieldByIndex(\"05\", \"1144\")\n\tgs.SetFieldByIndex(\"06\", \"1\")\n\tgs.SetFieldByIndex(\"07\", \"X\")\n\tgs.SetFieldByIndex(\"08\", \"004010\")\n\n\tge := segments.GE{}\n\tge.SetFieldByIndex(\"01\", \"1\")\n\tge.SetFieldByIndex(\"02\", \"1\")\n\n\tst := segments.ST{}\n\tst.SetFieldByIndex(\"01\", \"820\")\n\tst.SetFieldByIndex(\"02\", \"0001\")\n\n\tse := segments.SE{}\n\tse.SetFieldByIndex(\"01\", \"6\")\n\tse.SetFieldByIndex(\"02\", \"0001\")\n\n\tbpr := segments.BPR{}\n\tbpr.SetFieldByIndex(\"01\", \"C\")\n\tbpr.SetFieldByIndex(\"02\", \"7989.73\")\n\tbpr.SetFieldByIndex(\"03\", \"C\")\n\tbpr.SetFieldByIndex(\"04\", \"ACH\")\n\tbpr.SetFieldByIndex(\"05\", \"CTX\")\n\tbpr.SetFieldByIndex(\"10\", \"1657777777\")\n\tbpr.SetFieldByIndex(\"12\", \"01\")\n\tbpr.SetFieldByIndex(\"13\", \"148529553\")\n\tbpr.SetFieldByIndex(\"14\", \"DA\")\n\tbpr.SetFieldByIndex(\"15\", \"92283334\")\n\tbpr.SetFieldByIndex(\"16\", \"20120531\")\n\n\ttrn := segments.TRN{}\n\ttrn.SetFieldByIndex(\"01\", \"1\")\n\ttrn.SetFieldByIndex(\"02\", \"12053011440000192\")\n\n\tn11 := segments.N1{}\n\tn11.SetFieldByIndex(\"01\", \"PR\")\n\tn11.SetFieldByIndex(\"02\", \"YOUR COMPANY\")\n\tn11.SetFieldByIndex(\"03\", \"91\")\n\tn11.SetFieldByIndex(\"04\", \"227777777\")\n\n\tn12 := segments.N1{}\n\tn12.SetFieldByIndex(\"01\", \"PE\")\n\tn12.SetFieldByIndex(\"02\", \"WALMART\")\n\n\tnewInterchange := file.Interchange{\n\t\tISA: isa,\n\t\tIEA: \u0026iea,\n\t\tFunctionalGroups: []file.FunctionalGroup{\n\t\t\t{\n\t\t\t\tGS: gs,\n\t\t\t\tGE: \u0026ge,\n\t\t\t\tTransactionSets: []file.TransactionSet{\n\t\t\t\t\t{\n\t\t\t\t\t\tST:       st,\n\t\t\t\t\t\tSE:       \u0026se,\n\t\t\t\t\t\tSegments: []segments.SegmentInterface{\u0026bpr, \u0026trn, \u0026n11, \u0026n12},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tcopyRule := rule_stp_820.InterchangeRule\n\tif err := newInterchange.Validate(\u0026copyRule); err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\traw := `ISA*00* *00* *30*227777777 *14*577777777 *120530*1144*U*00401*000000001*0*P*~\\GS*RA*227777777*577777777*20120530*1144*1*X*004010\\ST*820*0001\\BPR*C*7989.73*C*ACH*CTX*****1657777777**01*148529553*DA*92283334*20120531\\TRN*1*12053011440000192\\N1*PR*YOUR COMPANY*91*227777777\\N1*PE*WALMART\\SE*6*0001\\GE*1*1\\IEA*1*000000001\\`\n\tif newInterchange.String(segmentTerminator) != raw {\n\t\tfmt.Println(\"invalid string\")\n\t}\n\n```\n\nWe need to know hierarchy of file, interchange or rule when editing new interchange.\n\nPlease use Print() function to verify edited interchange or target rule structure\n\n```\n\nfunc (f File) Print(w io.Writer)\n\nfunc (r Interchange) Print(w io.Writer)\n\nfunc (r InterchangeRule) Print(w io.Writer, isRequiredOnly bool)\n\n```\n\nFile print example\n```\n  DUMP EDI FILE WITH EPN STP 820\n\nINDEX:    | 00 | 01       | 02       | 03      | 04  | 05        | 06 | 07        | 08    | 09  | 10 | 11   | 12       | 13 | 14 | 15 | 16 |\nISA       |00  |          |00        |         |30   |227777777  |14  |577777777  |120530 |1144 |U   |00401 |000000001 |0   |P   |~   |\\   |\n GS       |RA  |227777777 |577777777 |20120530 |1144 |1          |X   |004010     |\\      |     |    |      |          |    |    |    |    |\n  ST      |820 |0001      |          |\\        |     |           |    |           |       |     |    |      |          |    |    |    |    |\n   Detail |    |          |          |         |     |           |    |           |       |     |    |      |          |    |    |    |    |\n    ENT   |1   |          |          |         |\\    |           |    |           |       |     |    |      |          |    |    |    |    |\n    RMR   |IV  |7321239   |          |953.19   |     |           |\\   |           |       |     |    |      |          |    |    |    |    |\n    REF   |PO  |24305     |          |\\        |     |           |    |           |       |     |    |      |          |    |    |    |    |\n   Detail |    |          |          |         |     |           |    |           |       |     |    |      |          |    |    |    |    |\n    RMR   |IV  |7321511   |          |7036.54  |     |           |\\   |           |       |     |    |      |          |    |    |    |    |\n    REF   |PO  |24333     |          |\\        |     |           |    |           |       |     |    |      |          |    |    |    |    |\n  SE      |11  |0001      |\\         |         |     |           |    |           |       |     |    |      |          |    |    |    |    |\n GE       |1   |1         |\\         |         |     |           |    |           |       |     |    |      |          |    |    |    |    |\nIEA       |1   |000000001 |\\         |         |     |           |    |           |       |     |    |      |          |    |    |    |    |\n```\n\nRule print example\n```\n  DUMP RULE EPN STP 820\n\nSegments \u0026 Rules Structure: | Usage   | Repeat Count | Description                                              |\nISA                         |REQUIRED |1             |INTERCHANGE CONTROL HEADER                                |\n GS                         |REQUIRED |1             |FUNCTIONAL GROUP HEADER                                   |\n  ST                        |REQUIRED |1             |TRANSACTION SET HEADER                                    |\n  BPR                       |REQUIRED |1             |Beginning Segment for Payment Order/Remittance Advice     |\n  TRN                       |REQUIRED |1             |Trace                                                     |\n  N1                        |REQUIRED |1             |Originator Name Identification                            |\n  N1                        |REQUIRED |1             |Receiver Name Identification                              |\n   Detail                   |OPTIONAL |\u003e1            |                                                          |\n    ENT                     |OPTIONAL |1             |Entity                                                    |\n    RMR                     |REQUIRED |1             |Remittance Advice Accounts Receivable Open Item Reference |\n    REF                     |OPTIONAL |\u003e1            |Reference Identification                                  |\n    DTM                     |OPTIONAL |1             |INDIVIDUAL COVERAGE PERIOD                                |\n    ADX                     |OPTIONAL |1             |Adjustment                                                |\n  SE                        |REQUIRED |1             |TRANSACTION SET TRAILER                                   |\n GE                         |REQUIRED |1             |FUNCTIONAL GROUP TRAILER                                  |\nIEA                         |REQUIRED |1             |INTERCHANGE CONTROL TRAILER                               |\n```\n\nRule print example with RequiredOnly option\n```\n  DUMP RULE EPN STP 820\n\nSegments \u0026 Rules Structure: | Usage   | Repeat Count | Description                                          |\nISA                         |REQUIRED |1             |INTERCHANGE CONTROL HEADER                            |\n GS                         |REQUIRED |1             |FUNCTIONAL GROUP HEADER                               |\n  ST                        |REQUIRED |1             |TRANSACTION SET HEADER                                |\n  BPR                       |REQUIRED |1             |Beginning Segment for Payment Order/Remittance Advice |\n  TRN                       |REQUIRED |1             |Trace                                                 |\n  N1                        |REQUIRED |1             |Originator Name Identification                        |\n  N1                        |REQUIRED |1             |Receiver Name Identification                          |\n  SE                        |REQUIRED |1             |TRANSACTION SET TRAILER                               |\n GE                         |REQUIRED |1             |FUNCTIONAL GROUP TRAILER                              |\nIEA                         |REQUIRED |1             |INTERCHANGE CONTROL TRAILER                           |\n```\n\n\nCheckout the [Go methods available](https://pkg.go.dev/github.com/moov-io/x12) for full details.\n\n\n### Error Messages\nX12 project used 2 error styles for parsing logic. \nFirst style used when getting error on any segment inside composite loop or loop, second type used for normal segment\n* reason, error stack, error line\n```\n  tds segment can't parse all input data, error segment line: 'TDS*139550*1*1*1*1~', error stack: 'functionalgroup-\u003etransactionset-\u003esummary-\u003etds'\n```\n\n* reason, error line\n```\n  ge segment contains invalid code, error segment line: 'ST*810*0002~'\n```\n\nX12 project used 2 error styles for validating logic.\nFirst style used when getting validate error on any segment inside composite loop or loop, second type used for normal segment\n* reason, error stack, error line\n```\n  segment(amt) don't accept specified rule(tds), please verify segment orders or has dirty segments as previous segment, error stack: 'functionalgroup-\u003etransactionset-\u003esummary-\u003eamt'\n```\n\n```\n  segment(amt) don't accept specified rule(tds), please verify segment orders or has dirty segments as previous segment\n```\n\n## Further Reading\n\n- [What makes EDI so hard?](https://www.stedi.com/blog/what-makes-edi-so-hard)\n- [awesome-edi](https://github.com/Stedi/awesome-edi)\n- EDI [catalog](https://www.stedi.com/edi/catalog) / [inspector](https://www.stedi.com/edi/inspector) / [reference](https://www.stedi.com/edi) (Stedi)\n\n## Getting help\n\nchannel | info\n------- | -------\n[Project Documentation](https://github.com/moov-io/x12) | Our project documentation available online.\nTwitter [@moov](https://twitter.com/moov)\t| You can follow Moov.io's Twitter feed to get updates on our project(s). You can also tweet us questions or just share blogs or stories.\n[GitHub Issue](https://github.com/moov-io/x12/issues/new) | If you are able to reproduce a problem please open a GitHub Issue under the specific project that caused the error.\n[moov-io slack](https://slack.moov.io/) | Join our slack channel (`x12`) to have an interactive discussion about the development of the project.\n\n## Contributing\n\nYes please! Please review our [Contributing guide](CONTRIBUTING.md) and [Code of Conduct](https://github.com/moov-io/ach/blob/master/CODE_OF_CONDUCT.md) to get started! Checkout our [issues for first time contributors](https://github.com/moov-io/x12/contribute) for something to help out with.\n\n## License\n\nApache License 2.0 - See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoov-io%2Fx12","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoov-io%2Fx12","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoov-io%2Fx12/lists"}