I'm working on an Automated CLearing House (ACH) application and I'm doing the file validations.
The first validation I need to validate that the ACH file has the correct pattern of record types.
The pattern is this:
1 - File Record Header
5 - Batch Record Header
6 - Entry Detail Record
7 - Addenda Record
8 - Batch Control Record
9 - File Control Record
The number is the record type or the first character of the line. The text describes the record type.
I want test that a file follows the above pattern..
Some variations including the following..
Addenda Record is not required
1 - File Record Header
5 - Batch Record Header
6 - Entry Detail Record
8 - Batch Control Record
9 - File Control Record
File can have one or more batches..
1 - File Record Header
5 - Batch Record Header
6 - Entry Detail Record
7 - Addenda Record
8 - Batch Control Record
5 - Batch Record Header
6 - Entry Detail Record
7 - Addenda Record
8 - Batch Control Record
5 - Batch Record Header
6 - Entry Detail Record
7 - Addenda Record
8 - Batch Control Record
9 - File Control Record
The File Record Header must be at the top of the file so the following would fail...
5 - Batch Record Header
1 - File Record Header
6 - Entry Detail Record
7 - Addenda Record
8 - Batch Control Record
9 - File Control Record
Would RegEx be best for this? Any advice would be greatly appreciated.