moov-io / ach

ACH implements a reader, writer, and validator for Automated Clearing House (ACH) files. The HTTP server is available in a Docker image and the Go package is available.
https://moov-io.github.io/ach/
Apache License 2.0
454 stars 150 forks source link

reader: static prefix breaks parsing #1037

Closed adamdecaf closed 1 year ago

adamdecaf commented 2 years ago

ACH Version: v1.18.1

What did you see? Vendors sometimes prefix lines with custom data that needs to be removed. Files and records are in Nacha format except for this prefix.

What did you expect to see? A handy way to strip these prefixes would help projects like ACHGateway to process these.

adamdecaf commented 2 years ago

@zbruhnke do you have an example for ACH?

adamdecaf commented 2 years ago

I think this is best solved with a ValidateOpts field for a prefix to strip off each line. Functions cannot be serialized across json/yaml so we can't implement a generic routine.

Should we have an array of prefixes to trim?

wadearnold commented 1 year ago

I assume this is only for the file reader and not JSON? Is this something that should be configurable or is there static vars that we can iterate over to avoid? I am sure we could put some logic in the Reader https://github.com/moov-io/ach/blob/master/reader.go#L114 or here https://github.com/moov-io/ach/blob/364497ec3bfe3928ac298ef436050ba9eb87dc48/reader.go#L160

adamdecaf commented 1 year ago

This is only for the Nacha format. It was a vendor applying a prefix, but the original reporter of this issue trimmed the files prior to parsing.

I don't know if this belongs in the library or not. It seems like a stretch to include strings.TrimPrefix(...) functionality when it can be easily called outside of moov-io/ach.

wadearnold commented 1 year ago

Should we close the ticket then?

On Fri, Dec 16, 2022, 3:34 PM Adam Shannon @.***> wrote:

This is only for the Nacha format. It was a vendor applying a prefix, but the original reporter of this issue trimmed the files prior to parsing.

— Reply to this email directly, view it on GitHub https://github.com/moov-io/ach/issues/1037#issuecomment-1355736208, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAIBXNPR2PAHDR5JZDOGU3WNTVBDANCNFSM52Z6IL2Q . You are receiving this because you commented.Message ID: @.***>