Skip to content

Commit cccb5f7

Browse files
committed
batch: check SkipAll inside Validate()
1 parent eecfec9 commit cccb5f7

23 files changed

+89
-1
lines changed

batchACK.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func NewBatchACK(bh *BatchHeader) *BatchACK {
3838
//
3939
// Validate will never modify the batch.
4040
func (batch *BatchACK) Validate() error {
41+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
42+
return nil
43+
}
44+
4145
// basic verification of the batch before we validate specific rules.
4246
if err := batch.verify(); err != nil {
4347
return err

batchADV.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func NewBatchADV(bh *BatchHeader) *BatchADV {
4040
//
4141
// Validate will never modify the batch.
4242
func (batch *BatchADV) Validate() error {
43+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
44+
return nil
45+
}
46+
4347
if batch.Header.StandardEntryClassCode != ADV {
4448
return batch.Error("StandardEntryClassCode", ErrBatchSECType, ADV)
4549
}

batchARC.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func NewBatchARC(bh *BatchHeader) *BatchARC {
4848
//
4949
// Validate will never modify the batch.
5050
func (batch *BatchARC) Validate() error {
51+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
52+
return nil
53+
}
54+
5155
// basic verification of the batch before we validate specific rules.
5256
if err := batch.verify(); err != nil {
5357
return err

batchATX.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func NewBatchATX(bh *BatchHeader) *BatchATX {
4444
//
4545
// Validate will never modify the batch.
4646
func (batch *BatchATX) Validate() error {
47+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
48+
return nil
49+
}
50+
4751
// basic verification of the batch before we validate specific rules.
4852
if err := batch.verify(); err != nil {
4953
return err

batchBOC.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func NewBatchBOC(bh *BatchHeader) *BatchBOC {
5353
//
5454
// Validate will never modify the batch.
5555
func (batch *BatchBOC) Validate() error {
56+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
57+
return nil
58+
}
59+
5660
// basic verification of the batch before we validate specific rules.
5761
if err := batch.verify(); err != nil {
5862
return err

batchCCD.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func NewBatchCCD(bh *BatchHeader) *BatchCCD {
3535

3636
// Validate ensures the batch meets NACHA rules specific to this batch type.
3737
func (batch *BatchCCD) Validate() error {
38+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
39+
return nil
40+
}
41+
3842
// basic verification of the batch before we validate specific rules.
3943
if err := batch.verify(); err != nil {
4044
return err

batchCIE.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func NewBatchCIE(bh *BatchHeader) *BatchCIE {
4444
//
4545
// Validate will never modify the batch.
4646
func (batch *BatchCIE) Validate() error {
47+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
48+
return nil
49+
}
50+
4751
// basic verification of the batch before we validate specific rules.
4852
if err := batch.verify(); err != nil {
4953
return err

batchCOR.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func NewBatchCOR(bh *BatchHeader) *BatchCOR {
3535

3636
// Validate ensures the batch meets NACHA rules specific to this batch type.
3737
func (batch *BatchCOR) Validate() error {
38+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
39+
return nil
40+
}
41+
3842
// basic verification of the batch before we validate specific rules.
3943
if err := batch.verify(); err != nil {
4044
return err

batchCTX.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func NewBatchCTX(bh *BatchHeader) *BatchCTX {
4545
//
4646
// Validate will never modify the batch.
4747
func (batch *BatchCTX) Validate() error {
48+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
49+
return nil
50+
}
51+
4852
// basic verification of the batch before we validate specific rules.
4953
if err := batch.verify(); err != nil {
5054
return err

batchDNE.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ func NewBatchDNE(bh *BatchHeader) *BatchDNE {
4646

4747
// Validate ensures the batch meets NACHA rules specific to this batch type.
4848
func (batch *BatchDNE) Validate() error {
49+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
50+
return nil
51+
}
52+
4953
if err := batch.verify(); err != nil {
5054
return err
5155
}

batchENR.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func NewBatchENR(bh *BatchHeader) *BatchENR {
4343

4444
// Validate ensures the batch meets NACHA rules specific to this batch type.
4545
func (batch *BatchENR) Validate() error {
46+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
47+
return nil
48+
}
49+
4650
if err := batch.verify(); err != nil {
4751
return err
4852
}

batchMTE.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func NewBatchMTE(bh *BatchHeader) *BatchMTE {
4545
//
4646
// Validate will never modify the batch.
4747
func (batch *BatchMTE) Validate() error {
48+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
49+
return nil
50+
}
51+
4852
// basic verification of the batch before we validate specific rules.
4953
if err := batch.verify(); err != nil {
5054
return err

batchPOP.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ func NewBatchPOP(bh *BatchHeader) *BatchPOP {
5050
//
5151
// Validate will never modify the batch.
5252
func (batch *BatchPOP) Validate() error {
53+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
54+
return nil
55+
}
56+
5357
// basic verification of the batch before we validate specific rules.
5458
if err := batch.verify(); err != nil {
5559
return err

batchPOS.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func NewBatchPOS(bh *BatchHeader) *BatchPOS {
5353
//
5454
// Validate will never modify the batch.
5555
func (batch *BatchPOS) Validate() error {
56+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
57+
return nil
58+
}
59+
5660
// basic verification of the batch before we validate specific rules.
5761
if err := batch.verify(); err != nil {
5862
return err

batchPPD.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func NewBatchPPD(bh *BatchHeader) *BatchPPD {
3636
//
3737
// Validate will never modify the batch.
3838
func (batch *BatchPPD) Validate() error {
39+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
40+
return nil
41+
}
42+
3943
// basic verification of the batch before we validate specific rules.
4044
if err := batch.verify(); err != nil {
4145
return err

batchRCK.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func NewBatchRCK(bh *BatchHeader) *BatchRCK {
3939
//
4040
// Validate will never modify the batch.
4141
func (batch *BatchRCK) Validate() error {
42+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
43+
return nil
44+
}
45+
4246
// basic verification of the batch before we validate specific rules.
4347
if err := batch.verify(); err != nil {
4448
return err

batchSHR.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func NewBatchSHR(bh *BatchHeader) *BatchSHR {
4848
//
4949
// Validate will never modify the batch.
5050
func (batch *BatchSHR) Validate() error {
51+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
52+
return nil
53+
}
54+
5155
// basic verification of the batch before we validate specific rules.
5256
if err := batch.verify(); err != nil {
5357
return err

batchTEL.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func NewBatchTEL(bh *BatchHeader) *BatchTEL {
3737

3838
// Validate ensures the batch meets NACHA rules specific to the SEC type TEL
3939
func (batch *BatchTEL) Validate() error {
40+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
41+
return nil
42+
}
43+
4044
// basic verification of the batch before we validate specific rules.
4145
if err := batch.verify(); err != nil {
4246
return err

batchTRC.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func NewBatchTRC(bh *BatchHeader) *BatchTRC {
3838
//
3939
// Validate will never modify the batch.
4040
func (batch *BatchTRC) Validate() error {
41+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
42+
return nil
43+
}
44+
4145
// basic verification of the batch before we validate specific rules.
4246
if err := batch.verify(); err != nil {
4347
return err

batchTRX.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func NewBatchTRX(bh *BatchHeader) *BatchTRX {
4242
//
4343
// Validate will never modify the batch.
4444
func (batch *BatchTRX) Validate() error {
45+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
46+
return nil
47+
}
48+
4549
// basic verification of the batch before we validate specific rules.
4650
if err := batch.verify(); err != nil {
4751
return err

batchWeb.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func NewBatchWEB(bh *BatchHeader) *BatchWEB {
3535

3636
// Validate ensures the batch meets NACHA rules specific to this batch type.
3737
func (batch *BatchWEB) Validate() error {
38+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
39+
return nil
40+
}
41+
3842
// basic verification of the batch before we validate specific rules.
3943
if err := batch.verify(); err != nil {
4044
return err

batchXCK.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func NewBatchXCK(bh *BatchHeader) *BatchXCK {
3838
//
3939
// Validate will never modify the batch.
4040
func (batch *BatchXCK) Validate() error {
41+
if batch.validateOpts != nil && batch.validateOpts.SkipAll {
42+
return nil
43+
}
44+
4145
// basic verification of the batch before we validate specific rules.
4246
if err := batch.verify(); err != nil {
4347
return err

reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,7 @@ func TestReadFile_SkipValidation(t *testing.T) {
21632163
t.Errorf("got: %v, want: %v (batched length)", len(f.Batches), 3)
21642164
} else {
21652165
for _, batch := range f.Batches {
2166-
require.Error(t, batch.Validate())
2166+
require.NoError(t, batch.Validate())
21672167
}
21682168
}
21692169

0 commit comments

Comments
 (0)