Skip to content

Commit

Permalink
MICR Valid Indicator is an optional field. (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin authored Feb 10, 2022
1 parent 6ffb118 commit a731763
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
39 changes: 22 additions & 17 deletions reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,29 @@ func TestICLFileRead(t *testing.T) {
}
}

// TestICLFile validates reading an ICL file
func TestICLFile(t *testing.T) {
fd, err := os.Open(filepath.Join("test", "testdata", "BNK20180905121042882-A.icl"))
if err != nil {
t.Fatalf("Can not open local file: %s: \n", err)
}
defer fd.Close()
// TestICLFile validates reading ICL files
func TestICLFiles(t *testing.T) {
files := []string{"BNK20180905121042882-A.icl", "without-micrValidIndicator.icl"}
for _, f := range files {
t.Run(f, func(t *testing.T) {
fd, err := os.Open(filepath.Join("test", "testdata", f))
if err != nil {
t.Fatalf("Can not open local file: %s: \n", err)
}
defer fd.Close()

r := NewReader(fd, ReadVariableLineLengthOption())
ICLFile, err := r.Read()
if err != nil {
t.Errorf("Issue reading file: %+v \n", err)
}
t.Logf("r.File.Header=%#v", r.File.Header)
t.Logf("r.File.Control=%#v", r.File.Control)
// ensure we have a validated file structure
if ICLFile.Validate(); err != nil {
t.Errorf("Could not validate entire read file: %v", err)
r := NewReader(fd, ReadVariableLineLengthOption())
ICLFile, err := r.Read()
if err != nil {
t.Errorf("Issue reading file: %+v \n", err)
}
t.Logf("r.File.Header=%#v", r.File.Header)
t.Logf("r.File.Control=%#v", r.File.Control)
// ensure we have a validated file structure
if ICLFile.Validate(); err != nil {
t.Errorf("Could not validate entire read file: %v", err)
}
})
}
}

Expand Down
Binary file added test/testdata/without-micrValidIndicator.icl
Binary file not shown.
2 changes: 2 additions & 0 deletions validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ func (v *validator) isReturnAcceptanceIndicator(code string) error {
func (v *validator) isMICRValidIndicator(code int) error {
switch code {
case
// Not specified (this field is conditional "Shall be present only under clearing arrangements")
0,
// Good read
1,
// Good read, missing field
Expand Down

0 comments on commit a731763

Please sign in to comment.