diff --git a/accountCreditedDrawdown.go b/accountCreditedDrawdown.go index 5b50d5dc..7d855e8d 100644 --- a/accountCreditedDrawdown.go +++ b/accountCreditedDrawdown.go @@ -35,7 +35,7 @@ func NewAccountCreditedDrawdown() *AccountCreditedDrawdown { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (creditDD *AccountCreditedDrawdown) Parse(record string) error { - if utf8.RuneCountInString(record) != 15 { + if utf8.RuneCountInString(record) != 15 { return NewTagWrongLengthErr(15, len(record)) } creditDD.tag = record[:6] diff --git a/accountCreditedDrawdown_test.go b/accountCreditedDrawdown_test.go index bd4ccdc5..b83bfc6a 100644 --- a/accountCreditedDrawdown_test.go +++ b/accountCreditedDrawdown_test.go @@ -79,4 +79,4 @@ func TestParseAccountCreditedDrawdownReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/accountDebitedDrawdown.go b/accountDebitedDrawdown.go index f57db591..e4b0d889 100644 --- a/accountDebitedDrawdown.go +++ b/accountDebitedDrawdown.go @@ -40,7 +40,7 @@ func NewAccountDebitedDrawdown() *AccountDebitedDrawdown { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (debitDD *AccountDebitedDrawdown) Parse(record string) error { - if utf8.RuneCountInString(record) != 181 { + if utf8.RuneCountInString(record) != 181 { return NewTagWrongLengthErr(181, len(record)) } debitDD.tag = record[:6] diff --git a/accountDebitedDrawdown_test.go b/accountDebitedDrawdown_test.go index faa9ffa5..1634b06e 100644 --- a/accountDebitedDrawdown_test.go +++ b/accountDebitedDrawdown_test.go @@ -172,4 +172,4 @@ func TestParseAccountDebitedDrawdownReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/amount_test.go b/amount_test.go index f81a0daf..9ecc1a40 100644 --- a/amount_test.go +++ b/amount_test.go @@ -79,4 +79,4 @@ func TestParseAmountReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/beneficiary.go b/beneficiary.go index 671f5312..cf263513 100644 --- a/beneficiary.go +++ b/beneficiary.go @@ -35,7 +35,7 @@ func NewBeneficiary() *Beneficiary { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (ben *Beneficiary) Parse(record string) error { - if utf8.RuneCountInString(record) != 181 { + if utf8.RuneCountInString(record) != 181 { return NewTagWrongLengthErr(181, len(record)) } ben.tag = record[:6] diff --git a/beneficiaryFI.go b/beneficiaryFI.go index 7500dabc..5b74d396 100644 --- a/beneficiaryFI.go +++ b/beneficiaryFI.go @@ -35,7 +35,7 @@ func NewBeneficiaryFI() *BeneficiaryFI { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (bfi *BeneficiaryFI) Parse(record string) error { - if utf8.RuneCountInString(record) != 181 { + if utf8.RuneCountInString(record) != 181 { return NewTagWrongLengthErr(181, len(record)) } bfi.tag = record[:6] diff --git a/beneficiaryFI_test.go b/beneficiaryFI_test.go index e1a4722e..280f7e9a 100644 --- a/beneficiaryFI_test.go +++ b/beneficiaryFI_test.go @@ -161,4 +161,4 @@ func TestParseBeneficiaryFIReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/beneficiaryIntermediaryFI.go b/beneficiaryIntermediaryFI.go index 0ca60c2e..e1a04417 100644 --- a/beneficiaryIntermediaryFI.go +++ b/beneficiaryIntermediaryFI.go @@ -35,7 +35,7 @@ func NewBeneficiaryIntermediaryFI() *BeneficiaryIntermediaryFI { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (bifi *BeneficiaryIntermediaryFI) Parse(record string) error { - if utf8.RuneCountInString(record) != 181 { + if utf8.RuneCountInString(record) != 181 { return NewTagWrongLengthErr(181, len(record)) } bifi.tag = record[:6] diff --git a/beneficiaryIntermediaryFI_test.go b/beneficiaryIntermediaryFI_test.go index 3ddcc166..46bb6ee2 100644 --- a/beneficiaryIntermediaryFI_test.go +++ b/beneficiaryIntermediaryFI_test.go @@ -161,4 +161,4 @@ func TestParseBeneficiaryIntermediaryFIReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/beneficiaryReference.go b/beneficiaryReference.go index ea7803b4..c9744076 100644 --- a/beneficiaryReference.go +++ b/beneficiaryReference.go @@ -35,7 +35,7 @@ func NewBeneficiaryReference() *BeneficiaryReference { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (br *BeneficiaryReference) Parse(record string) error { - if utf8.RuneCountInString(record) != 22 { + if utf8.RuneCountInString(record) != 22 { return NewTagWrongLengthErr(22, len(record)) } br.tag = record[:6] diff --git a/beneficiaryReference_test.go b/beneficiaryReference_test.go index 34a1b412..da30297c 100644 --- a/beneficiaryReference_test.go +++ b/beneficiaryReference_test.go @@ -68,4 +68,4 @@ func TestParseBeneficiaryReferenceReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/beneficiary_test.go b/beneficiary_test.go index 140ed171..48adc9e1 100644 --- a/beneficiary_test.go +++ b/beneficiary_test.go @@ -150,4 +150,4 @@ func TestParseBeneficiaryReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/businessFunctionCode_test.go b/businessFunctionCode_test.go index 4ce51875..1bab2899 100644 --- a/businessFunctionCode_test.go +++ b/businessFunctionCode_test.go @@ -80,4 +80,4 @@ func TestParseBusinessFunctionCodeReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/exchangeRate.go b/exchangeRate.go index e4657007..2237d9f8 100644 --- a/exchangeRate.go +++ b/exchangeRate.go @@ -36,7 +36,7 @@ func NewExchangeRate() *ExchangeRate { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (eRate *ExchangeRate) Parse(record string) error { - if utf8.RuneCountInString(record) != 18 { + if utf8.RuneCountInString(record) != 18 { return NewTagWrongLengthErr(18, len(record)) } eRate.tag = record[:6] diff --git a/exchangeRate_test.go b/exchangeRate_test.go index d028d829..ae4a1199 100644 --- a/exchangeRate_test.go +++ b/exchangeRate_test.go @@ -68,4 +68,4 @@ func TestParseExchangeRateReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/fiAdditionalFIToFI.go b/fiAdditionalFIToFI.go index cea4f012..87171482 100644 --- a/fiAdditionalFIToFI.go +++ b/fiAdditionalFIToFI.go @@ -4,7 +4,10 @@ package wire -import "strings" +import ( + "strings" + "unicode/utf8" +) // FIAdditionalFIToFI is the financial institution beneficiary financial institution type FIAdditionalFIToFI struct { @@ -31,20 +34,24 @@ func NewFIAdditionalFIToFI() *FIAdditionalFIToFI { // // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. -func (fifi *FIAdditionalFIToFI) Parse(record string) { +func (fifi *FIAdditionalFIToFI) Parse(record string) error { + if utf8.RuneCountInString(record) != 216 { + return NewTagWrongLengthErr(216, len(record)) + } fifi.tag = record[:6] - fifi.AdditionalFIToFI.LineOne = fifi.parseStringField(record[6:36]) - fifi.AdditionalFIToFI.LineTwo = fifi.parseStringField(record[36:71]) - fifi.AdditionalFIToFI.LineThree = fifi.parseStringField(record[71:106]) - fifi.AdditionalFIToFI.LineFour = fifi.parseStringField(record[106:141]) - fifi.AdditionalFIToFI.LineFive = fifi.parseStringField(record[141:176]) - fifi.AdditionalFIToFI.LineSix = fifi.parseStringField(record[176:211]) + fifi.AdditionalFIToFI.LineOne = fifi.parseStringField(record[6:41]) + fifi.AdditionalFIToFI.LineTwo = fifi.parseStringField(record[41:76]) + fifi.AdditionalFIToFI.LineThree = fifi.parseStringField(record[76:111]) + fifi.AdditionalFIToFI.LineFour = fifi.parseStringField(record[111:146]) + fifi.AdditionalFIToFI.LineFive = fifi.parseStringField(record[146:181]) + fifi.AdditionalFIToFI.LineSix = fifi.parseStringField(record[181:216]) + return nil } // String writes FIAdditionalFIToFI func (fifi *FIAdditionalFIToFI) String() string { var buf strings.Builder - buf.Grow(211) + buf.Grow(216) buf.WriteString(fifi.tag) buf.WriteString(fifi.LineOneField()) buf.WriteString(fifi.LineTwoField()) diff --git a/fiAdditionalFIToFI_test.go b/fiAdditionalFIToFI_test.go index 6d280ae3..b8d6b1a8 100644 --- a/fiAdditionalFIToFI_test.go +++ b/fiAdditionalFIToFI_test.go @@ -2,6 +2,7 @@ package wire import ( "github.com/moov-io/base" + "strings" "testing" ) @@ -90,3 +91,41 @@ func TestFIAdditionalFIToFILineSixAlphaNumeric(t *testing.T) { } } } + +// TestParseFIAdditionalFIToFIWrongLength parses a wrong FIAdditionalFIToFI record length +func TestParseFIAdditionalFIToFIWrongLength(t *testing.T) { + var line = "{6500}Line One Line Two Line Three Line Four Line Five Line Six " + r := NewReader(strings.NewReader(line)) + r.line = line + fwm := new(FEDWireMessage) + fifi := mockFIAdditionalFIToFI() + fwm.SetFIAdditionalFIToFI(fifi) + err := r.parseFIAdditionalFIToFI() + if err != nil { + if !base.Match(err, NewTagWrongLengthErr(216, len(r.line))) { + t.Errorf("%T: %s", err, err) + } + } +} + +// TestParseFIAdditionalFIToFIReaderParseError parses a wrong FIAdditionalFIToFI reader parse error +func TestParseFIAdditionalFIToFIReaderParseError(t *testing.T) { + var line = "{6500}®ine One Line Two Line Three Line Four Line Five Line Six " + r := NewReader(strings.NewReader(line)) + r.line = line + fwm := new(FEDWireMessage) + fifi := mockFIAdditionalFIToFI() + fwm.SetFIAdditionalFIToFI(fifi) + err := r.parseFIAdditionalFIToFI() + if err != nil { + if !base.Match(err, ErrNonAlphanumeric) { + t.Errorf("%T: %s", err, err) + } + } + _, err = r.Read() + if err != nil { + if !base.Has(err, ErrNonAlphanumeric) { + t.Errorf("%T: %s", err, err) + } + } +} diff --git a/fiBeneficiary.go b/fiBeneficiary.go index 2b8eaaa2..8f7d1253 100644 --- a/fiBeneficiary.go +++ b/fiBeneficiary.go @@ -4,7 +4,10 @@ package wire -import "strings" +import ( + "strings" + "unicode/utf8" +) // FIBeneficiary is the financial institution beneficiary type FIBeneficiary struct { @@ -31,7 +34,10 @@ func NewFIBeneficiary() *FIBeneficiary { // // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. -func (fib *FIBeneficiary) Parse(record string) { +func (fib *FIBeneficiary) Parse(record string) error { + if utf8.RuneCountInString(record) != 201 { + return NewTagWrongLengthErr(201, len(record)) + } fib.tag = record[:6] fib.FIToFI.LineOne = fib.parseStringField(record[6:36]) fib.FIToFI.LineTwo = fib.parseStringField(record[36:69]) @@ -39,6 +45,7 @@ func (fib *FIBeneficiary) Parse(record string) { fib.FIToFI.LineFour = fib.parseStringField(record[102:135]) fib.FIToFI.LineFive = fib.parseStringField(record[135:168]) fib.FIToFI.LineSix = fib.parseStringField(record[168:201]) + return nil } // String writes FIBeneficiary diff --git a/fiBeneficiaryFI.go b/fiBeneficiaryFI.go index d619e4a0..4df10084 100644 --- a/fiBeneficiaryFI.go +++ b/fiBeneficiaryFI.go @@ -4,7 +4,10 @@ package wire -import "strings" +import ( + "strings" + "unicode/utf8" +) // FIBeneficiaryFI is the financial institution beneficiary financial institution type FIBeneficiaryFI struct { @@ -31,7 +34,10 @@ func NewFIBeneficiaryFI() *FIBeneficiaryFI { // // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. -func (fibfi *FIBeneficiaryFI) Parse(record string) { +func (fibfi *FIBeneficiaryFI) Parse(record string) error { + if utf8.RuneCountInString(record) != 201 { + return NewTagWrongLengthErr(201, len(record)) + } fibfi.tag = record[:6] fibfi.FIToFI.LineOne = fibfi.parseStringField(record[6:36]) fibfi.FIToFI.LineTwo = fibfi.parseStringField(record[36:69]) @@ -39,6 +45,7 @@ func (fibfi *FIBeneficiaryFI) Parse(record string) { fibfi.FIToFI.LineFour = fibfi.parseStringField(record[102:135]) fibfi.FIToFI.LineFive = fibfi.parseStringField(record[135:168]) fibfi.FIToFI.LineSix = fibfi.parseStringField(record[168:201]) + return nil } // String writes FIBeneficiaryFI diff --git a/fiBeneficiaryFI_test.go b/fiBeneficiaryFI_test.go index 66a87bb4..6a247d8c 100644 --- a/fiBeneficiaryFI_test.go +++ b/fiBeneficiaryFI_test.go @@ -2,6 +2,7 @@ package wire import ( "github.com/moov-io/base" + "strings" "testing" ) @@ -90,3 +91,41 @@ func TestFIBeneficiaryFILineSixAlphaNumeric(t *testing.T) { } } } + +// TestParseFIBeneficiaryFIWrongLength parses a wrong FIBeneficiaryFI record length +func TestParseFIBeneficiaryFIWrongLength(t *testing.T) { + var line = "{6100}Line Six " + r := NewReader(strings.NewReader(line)) + r.line = line + fwm := new(FEDWireMessage) + fibfi := mockFIBeneficiaryFI() + fwm.SetFIBeneficiaryFI(fibfi) + err := r.parseFIBeneficiaryFI() + if err != nil { + if !base.Match(err, NewTagWrongLengthErr(201, len(r.line))) { + t.Errorf("%T: %s", err, err) + } + } +} + +// TestParseFIBeneficiaryFIReaderParseError parses a wrong FIBeneficiaryFI reader parse error +func TestParseFIBeneficiaryFIReaderParseError(t *testing.T) { + var line = "{6100}Line Si® " + r := NewReader(strings.NewReader(line)) + r.line = line + fwm := new(FEDWireMessage) + fibfi := mockFIBeneficiaryFI() + fwm.SetFIBeneficiaryFI(fibfi) + err := r.parseFIBeneficiaryFI() + if err != nil { + if !base.Match(err, ErrNonAlphanumeric) { + t.Errorf("%T: %s", err, err) + } + } + _, err = r.Read() + if err != nil { + if !base.Has(err, ErrNonAlphanumeric) { + t.Errorf("%T: %s", err, err) + } + } +} diff --git a/fiBeneficiary_test.go b/fiBeneficiary_test.go index 79f8f159..b4635631 100644 --- a/fiBeneficiary_test.go +++ b/fiBeneficiary_test.go @@ -2,6 +2,7 @@ package wire import ( "github.com/moov-io/base" + "strings" "testing" ) @@ -90,3 +91,41 @@ func TestFIBeneficiaryLineSixAlphaNumeric(t *testing.T) { } } } + +// TestParseFIBeneficiaryWrongLength parses a wrong FIBeneficiary record length +func TestParseFIBeneficiaryWrongLength(t *testing.T) { + var line = "{6100}Line Six " + r := NewReader(strings.NewReader(line)) + r.line = line + fwm := new(FEDWireMessage) + fib := mockFIBeneficiary() + fwm.SetFIBeneficiary(fib) + err := r.parseFIBeneficiary() + if err != nil { + if !base.Match(err, NewTagWrongLengthErr(201, len(r.line))) { + t.Errorf("%T: %s", err, err) + } + } +} + +// TestParseFIBeneficiaryReaderParseError parses a wrong FIBeneficiary reader parse error +func TestParseFIBeneficiaryReaderParseError(t *testing.T) { + var line = "{6100}Line Si® " + r := NewReader(strings.NewReader(line)) + r.line = line + fwm := new(FEDWireMessage) + fib := mockFIBeneficiary() + fwm.SetFIBeneficiary(fib) + err := r.parseFIBeneficiary() + if err != nil { + if !base.Match(err, ErrNonAlphanumeric) { + t.Errorf("%T: %s", err, err) + } + } + _, err = r.Read() + if err != nil { + if !base.Has(err, ErrNonAlphanumeric) { + t.Errorf("%T: %s", err, err) + } + } +} diff --git a/fiIntermediaryFI.go b/fiIntermediaryFI.go index bc7bdf68..5a2e03f3 100644 --- a/fiIntermediaryFI.go +++ b/fiIntermediaryFI.go @@ -4,7 +4,10 @@ package wire -import "strings" +import ( + "strings" + "unicode/utf8" +) // FIIntermediaryFI is the financial institution intermediary financial institution type FIIntermediaryFI struct { @@ -31,7 +34,10 @@ func NewFIIntermediaryFI() *FIIntermediaryFI { // // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. -func (fiifi *FIIntermediaryFI) Parse(record string) { +func (fiifi *FIIntermediaryFI) Parse(record string) error { + if utf8.RuneCountInString(record) != 201 { + return NewTagWrongLengthErr(201, len(record)) + } fiifi.tag = record[:6] fiifi.FIToFI.LineOne = fiifi.parseStringField(record[6:36]) fiifi.FIToFI.LineTwo = fiifi.parseStringField(record[36:69]) @@ -39,6 +45,7 @@ func (fiifi *FIIntermediaryFI) Parse(record string) { fiifi.FIToFI.LineFour = fiifi.parseStringField(record[102:135]) fiifi.FIToFI.LineFive = fiifi.parseStringField(record[135:168]) fiifi.FIToFI.LineSix = fiifi.parseStringField(record[168:201]) + return nil } // String writes FIIntermediaryFI diff --git a/fiIntermediaryFI_test.go b/fiIntermediaryFI_test.go index 6f9165b0..a3ad33c9 100644 --- a/fiIntermediaryFI_test.go +++ b/fiIntermediaryFI_test.go @@ -2,6 +2,7 @@ package wire import ( "github.com/moov-io/base" + "strings" "testing" ) @@ -90,3 +91,41 @@ func TestFIIntermediaryFILineSixAlphaNumeric(t *testing.T) { } } } + +// TestParseFIIntermediaryFIWrongLength parses a wrong FIIntermediaryFI record length +func TestParseFIIntermediaryFIWrongLength(t *testing.T) { + var line = "{6100}Line Six " + r := NewReader(strings.NewReader(line)) + r.line = line + fwm := new(FEDWireMessage) + fiifi := mockFIIntermediaryFI() + fwm.SetFIIntermediaryFI(fiifi) + err := r.parseFIIntermediaryFI() + if err != nil { + if !base.Match(err, NewTagWrongLengthErr(201, len(r.line))) { + t.Errorf("%T: %s", err, err) + } + } +} + +// TestParseFIIntermediaryFIReaderParseError parses a wrong FIIntermediaryFI reader parse error +func TestParseFIIntermediaryFIReaderParseError(t *testing.T) { + var line = "{6100}Line Si® " + r := NewReader(strings.NewReader(line)) + r.line = line + fwm := new(FEDWireMessage) + fiifi := mockFIIntermediaryFI() + fwm.SetFIIntermediaryFI(fiifi) + err := r.parseFIIntermediaryFI() + if err != nil { + if !base.Match(err, ErrNonAlphanumeric) { + t.Errorf("%T: %s", err, err) + } + } + _, err = r.Read() + if err != nil { + if !base.Has(err, ErrNonAlphanumeric) { + t.Errorf("%T: %s", err, err) + } + } +} diff --git a/fiReceiverFI.go b/fiReceiverFI.go index 1a6b7274..9035ee76 100644 --- a/fiReceiverFI.go +++ b/fiReceiverFI.go @@ -35,7 +35,7 @@ func NewFIReceiverFI() *FIReceiverFI { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (firfi *FIReceiverFI) Parse(record string) error { - if utf8.RuneCountInString(record) != 201 { + if utf8.RuneCountInString(record) != 201 { return NewTagWrongLengthErr(201, len(record)) } firfi.tag = record[:6] diff --git a/fiReceiverFI_test.go b/fiReceiverFI_test.go index d71c1a93..1faea72c 100644 --- a/fiReceiverFI_test.go +++ b/fiReceiverFI_test.go @@ -102,7 +102,7 @@ func TestParseFIReceiverFIWrongLength(t *testing.T) { fwm.SetFIReceiverFI(firfi) err := r.parseFIReceiverFI() if err != nil { - if !base.Match(err, NewTagWrongLengthErr(181, len(r.line))) { + if !base.Match(err, NewTagWrongLengthErr(201, len(r.line))) { t.Errorf("%T: %s", err, err) } } @@ -128,4 +128,4 @@ func TestParseFIReceiverFIReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/inputMessageAccountabilityData_test.go b/inputMessageAccountabilityData_test.go index d9a2cfb0..89bd979d 100644 --- a/inputMessageAccountabilityData_test.go +++ b/inputMessageAccountabilityData_test.go @@ -119,4 +119,4 @@ func TestParseInputMessageAccountabilityDataReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/instructedAmount_test.go b/instructedAmount_test.go index 84ad9a91..0dc23268 100644 --- a/instructedAmount_test.go +++ b/instructedAmount_test.go @@ -102,4 +102,4 @@ func TestParseInstructedAmountReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/instructingFI.go b/instructingFI.go index 52de8fa7..d8f9acc1 100644 --- a/instructingFI.go +++ b/instructingFI.go @@ -35,7 +35,7 @@ func NewInstructingFI() *InstructingFI { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (ifi *InstructingFI) Parse(record string) error { - if utf8.RuneCountInString(record) != 181 { + if utf8.RuneCountInString(record) != 181 { return NewTagWrongLengthErr(181, len(record)) } ifi.tag = record[:6] diff --git a/instructingFI_test.go b/instructingFI_test.go index bf8453b5..54c22d00 100644 --- a/instructingFI_test.go +++ b/instructingFI_test.go @@ -161,4 +161,4 @@ func TestParseInstructingFIReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/localInstrument.go b/localInstrument.go index 807c3847..3e9ede14 100644 --- a/localInstrument.go +++ b/localInstrument.go @@ -37,7 +37,7 @@ func NewLocalInstrument() *LocalInstrument { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (li *LocalInstrument) Parse(record string) error { - if utf8.RuneCountInString(record) != 45 { + if utf8.RuneCountInString(record) != 45 { return NewTagWrongLengthErr(45, len(record)) } li.tag = record[:6] diff --git a/localInstrument_test.go b/localInstrument_test.go index 5ad26933..530a1e37 100644 --- a/localInstrument_test.go +++ b/localInstrument_test.go @@ -92,4 +92,4 @@ func TestParseLocalInstrumentReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/originator.go b/originator.go index c33b6811..d5cca34f 100644 --- a/originator.go +++ b/originator.go @@ -35,7 +35,7 @@ func NewOriginator() *Originator { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (o *Originator) Parse(record string) error { - if utf8.RuneCountInString(record) != 181 { + if utf8.RuneCountInString(record) != 181 { return NewTagWrongLengthErr(181, len(record)) } o.tag = record[:6] diff --git a/originatorFI.go b/originatorFI.go index 03c9b919..bc6b1bc4 100644 --- a/originatorFI.go +++ b/originatorFI.go @@ -35,7 +35,7 @@ func NewOriginatorFI() *OriginatorFI { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (ofi *OriginatorFI) Parse(record string) error { - if utf8.RuneCountInString(record) != 181 { + if utf8.RuneCountInString(record) != 181 { return NewTagWrongLengthErr(181, len(record)) } ofi.tag = record[:6] diff --git a/originatorFI_test.go b/originatorFI_test.go index 7bf49b32..b10338d9 100644 --- a/originatorFI_test.go +++ b/originatorFI_test.go @@ -161,4 +161,4 @@ func TestParseOriginatorFIReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/originatorOptionF.go b/originatorOptionF.go index 72f666b3..c4241739 100644 --- a/originatorOptionF.go +++ b/originatorOptionF.go @@ -95,7 +95,7 @@ func NewOriginatorOptionF() *OriginatorOptionF { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (oof *OriginatorOptionF) Parse(record string) error { - if utf8.RuneCountInString(record) != 181 { + if utf8.RuneCountInString(record) != 181 { return NewTagWrongLengthErr(181, len(record)) } oof.tag = oof.parseStringField(record[:6]) diff --git a/originatorOptionF_test.go b/originatorOptionF_test.go index 9f6d033f..d0a98a14 100644 --- a/originatorOptionF_test.go +++ b/originatorOptionF_test.go @@ -98,7 +98,7 @@ func TestParseOriginatorOptionFWrongLength(t *testing.T) { // TestParseOriginatorOptionFReaderParseError parses a wrong OriginatorOptionF reader parse error func TestParseOriginatorOptionFReaderParseError(t *testing.T) { - var line = "{5010}TXID/123-45-6789 Name LineOne LineTwo LineThree " + var line = "{5010}TXID/123-45-6789 ®ame LineOne LineTwo LineThree " r := NewReader(strings.NewReader(line)) r.line = line fwm := new(FEDWireMessage) @@ -116,4 +116,4 @@ func TestParseOriginatorOptionFReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/originatorToBeneficiary.go b/originatorToBeneficiary.go index 335c7e2e..745b81bf 100644 --- a/originatorToBeneficiary.go +++ b/originatorToBeneficiary.go @@ -41,7 +41,7 @@ func NewOriginatorToBeneficiary() *OriginatorToBeneficiary { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (ob *OriginatorToBeneficiary) Parse(record string) error { - if utf8.RuneCountInString(record) != 146 { + if utf8.RuneCountInString(record) != 146 { return NewTagWrongLengthErr(146, len(record)) } ob.tag = record[:6] diff --git a/originatorToBeneficiary_test.go b/originatorToBeneficiary_test.go index 35bfbba5..cec2783d 100644 --- a/originatorToBeneficiary_test.go +++ b/originatorToBeneficiary_test.go @@ -104,4 +104,4 @@ func TestParseOriginatorToBeneficiaryReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/originator_test.go b/originator_test.go index 41164a3e..b17059da 100644 --- a/originator_test.go +++ b/originator_test.go @@ -150,4 +150,4 @@ func TestParseOriginatorReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/paymentNotification.go b/paymentNotification.go index 58c64237..6f5e10df 100644 --- a/paymentNotification.go +++ b/paymentNotification.go @@ -50,7 +50,7 @@ func NewPaymentNotification() *PaymentNotification { // Parse provides no guarantee about all fields being filled in. Callers should make a Validate() call to confirm // successful parsing and data validity. func (pn *PaymentNotification) Parse(record string) error { - if utf8.RuneCountInString(record) != 2335 { + if utf8.RuneCountInString(record) != 2335 { return NewTagWrongLengthErr(2335, len(record)) } pn.tag = record[:6] diff --git a/paymentNotification_test.go b/paymentNotification_test.go index 885392eb..4b26fd00 100644 --- a/paymentNotification_test.go +++ b/paymentNotification_test.go @@ -140,4 +140,4 @@ func TestParsePaymentNotificationReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/previousMessageIdentifier_test.go b/previousMessageIdentifier_test.go index c4ea9c67..5486a546 100644 --- a/previousMessageIdentifier_test.go +++ b/previousMessageIdentifier_test.go @@ -68,4 +68,4 @@ func TestParsePreviousMessageIdentifierReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/reader.go b/reader.go index f18c7a6a..72fd8a22 100644 --- a/reader.go +++ b/reader.go @@ -222,7 +222,7 @@ func (r *Reader) parseLine() error { return err } case TagFIAdditionalFIToFI: - if err := r.parseFIAdditionalFiToFi(); err != nil { + if err := r.parseFIAdditionalFIToFI(); err != nil { return err } case TagCurrencyInstructedAmount: @@ -322,7 +322,7 @@ func (r *Reader) parseLine() error { func (r *Reader) parseSenderSupplied() error { r.tagName = "SenderSupplied" ss := new(SenderSupplied) - if err:= ss.Parse(r.line); err != nil { + if err := ss.Parse(r.line); err != nil { return r.parseError(err) } if err := ss.Validate(); err != nil { @@ -335,7 +335,7 @@ func (r *Reader) parseSenderSupplied() error { func (r *Reader) parseTypeSubType() error { r.tagName = "TypeSubType" tst := new(TypeSubType) - if err:= tst.Parse(r.line); err != nil { + if err := tst.Parse(r.line); err != nil { return r.parseError(err) } if err := tst.Validate(); err != nil { @@ -348,7 +348,7 @@ func (r *Reader) parseTypeSubType() error { func (r *Reader) parseInputMessageAccountabilityData() error { r.tagName = "InputMessageAccountabilityData" imad := new(InputMessageAccountabilityData) - if err:= imad.Parse(r.line); err != nil { + if err := imad.Parse(r.line); err != nil { return r.parseError(err) } if err := imad.Validate(); err != nil { @@ -361,7 +361,7 @@ func (r *Reader) parseInputMessageAccountabilityData() error { func (r *Reader) parseAmount() error { r.tagName = "Amount" amt := new(Amount) - if err:= amt.Parse(r.line); err != nil { + if err := amt.Parse(r.line); err != nil { return r.parseError(err) } if err := amt.Validate(); err != nil { @@ -374,7 +374,7 @@ func (r *Reader) parseAmount() error { func (r *Reader) parseSenderDepositoryInstitution() error { r.tagName = "SenderDepositoryInstitution" sdi := new(SenderDepositoryInstitution) - if err:= sdi.Parse(r.line); err != nil { + if err := sdi.Parse(r.line); err != nil { return r.parseError(err) } if err := sdi.Validate(); err != nil { @@ -387,7 +387,7 @@ func (r *Reader) parseSenderDepositoryInstitution() error { func (r *Reader) parseReceiverDepositoryInstitution() error { r.tagName = "ReceiverDepositoryInstitution" rdi := new(ReceiverDepositoryInstitution) - if err:= rdi.Parse(r.line); err != nil { + if err := rdi.Parse(r.line); err != nil { return r.parseError(err) } if err := rdi.Validate(); err != nil { @@ -413,7 +413,7 @@ func (r *Reader) parseBusinessFunctionCode() error { func (r *Reader) parseSenderReference() error { r.tagName = "SenderReference" sr := new(SenderReference) - if err:= sr.Parse(r.line); err != nil { + if err := sr.Parse(r.line); err != nil { return r.parseError(err) } if err := sr.Validate(); err != nil { @@ -426,7 +426,7 @@ func (r *Reader) parseSenderReference() error { func (r *Reader) parsePreviousMessageIdentifier() error { r.tagName = "PreviousMessageIdentifier" pmi := new(PreviousMessageIdentifier) - if err:= pmi.Parse(r.line); err != nil { + if err := pmi.Parse(r.line); err != nil { return r.parseError(err) } if err := pmi.Validate(); err != nil { @@ -439,7 +439,7 @@ func (r *Reader) parsePreviousMessageIdentifier() error { func (r *Reader) parseLocalInstrument() error { r.tagName = "LocalInstrument" li := new(LocalInstrument) - if err:= li.Parse(r.line); err != nil { + if err := li.Parse(r.line); err != nil { return r.parseError(err) } if err := li.Validate(); err != nil { @@ -452,7 +452,7 @@ func (r *Reader) parseLocalInstrument() error { func (r *Reader) parsePaymentNotification() error { r.tagName = "PaymentNotification" pn := new(PaymentNotification) - if err:= pn.Parse(r.line); err != nil { + if err := pn.Parse(r.line); err != nil { return r.parseError(err) } if err := pn.Validate(); err != nil { @@ -476,7 +476,7 @@ func (r *Reader) parseCharges() error { func (r *Reader) parseInstructedAmount() error { r.tagName = "InstructedAmount" ia := new(InstructedAmount) - if err:= ia.Parse(r.line); err != nil { + if err := ia.Parse(r.line); err != nil { return r.parseError(err) } if err := ia.Validate(); err != nil { @@ -489,7 +489,7 @@ func (r *Reader) parseInstructedAmount() error { func (r *Reader) parseExchangeRate() error { r.tagName = "ExchangeRate" eRate := new(ExchangeRate) - if err:= eRate.Parse(r.line); err != nil { + if err := eRate.Parse(r.line); err != nil { return r.parseError(err) } if err := eRate.Validate(); err != nil { @@ -502,7 +502,7 @@ func (r *Reader) parseExchangeRate() error { func (r *Reader) parseBeneficiaryIntermediaryFI() error { r.tagName = "BeneficiaryIntermediaryFI" bifi := new(BeneficiaryIntermediaryFI) - if err:= bifi.Parse(r.line); err != nil { + if err := bifi.Parse(r.line); err != nil { return r.parseError(err) } if err := bifi.Validate(); err != nil { @@ -515,7 +515,7 @@ func (r *Reader) parseBeneficiaryIntermediaryFI() error { func (r *Reader) parseBeneficiaryFI() error { r.tagName = "BeneficiaryFI" bfi := new(BeneficiaryFI) - if err:= bfi.Parse(r.line); err != nil { + if err := bfi.Parse(r.line); err != nil { return r.parseError(err) } if err := bfi.Validate(); err != nil { @@ -528,7 +528,7 @@ func (r *Reader) parseBeneficiaryFI() error { func (r *Reader) parseBeneficiary() error { r.tagName = "Beneficiary" ben := new(Beneficiary) - if err:= ben.Parse(r.line); err != nil { + if err := ben.Parse(r.line); err != nil { return r.parseError(err) } if err := ben.Validate(); err != nil { @@ -541,7 +541,7 @@ func (r *Reader) parseBeneficiary() error { func (r *Reader) parseBeneficiaryReference() error { r.tagName = "BeneficiaryReference" br := new(BeneficiaryReference) - if err:= br.Parse(r.line); err != nil { + if err := br.Parse(r.line); err != nil { return r.parseError(err) } if err := br.Validate(); err != nil { @@ -554,7 +554,7 @@ func (r *Reader) parseBeneficiaryReference() error { func (r *Reader) parseAccountDebitedDrawdown() error { r.tagName = "AccountDebitedDrawdown" debitDD := new(AccountDebitedDrawdown) - if err:= debitDD.Parse(r.line); err != nil { + if err := debitDD.Parse(r.line); err != nil { return r.parseError(err) } if err := debitDD.Validate(); err != nil { @@ -567,7 +567,7 @@ func (r *Reader) parseAccountDebitedDrawdown() error { func (r *Reader) parseOriginator() error { r.tagName = "Originator" o := new(Originator) - if err:= o.Parse(r.line); err != nil { + if err := o.Parse(r.line); err != nil { return r.parseError(err) } if err := o.Validate(); err != nil { @@ -580,7 +580,7 @@ func (r *Reader) parseOriginator() error { func (r *Reader) parseOriginatorOptionF() error { r.tagName = "OriginatorOptionF" oof := new(OriginatorOptionF) - if err:= oof.Parse(r.line); err != nil { + if err := oof.Parse(r.line); err != nil { return r.parseError(err) } if err := oof.Validate(); err != nil { @@ -593,7 +593,7 @@ func (r *Reader) parseOriginatorOptionF() error { func (r *Reader) parseOriginatorFI() error { r.tagName = "OriginatorFI" ofi := new(OriginatorFI) - if err:= ofi.Parse(r.line); err != nil { + if err := ofi.Parse(r.line); err != nil { return r.parseError(err) } if err := ofi.Validate(); err != nil { @@ -606,7 +606,7 @@ func (r *Reader) parseOriginatorFI() error { func (r *Reader) parseInstructingFI() error { r.tagName = "InstructingFI" ifi := new(InstructingFI) - if err:= ifi.Parse(r.line); err != nil { + if err := ifi.Parse(r.line); err != nil { return r.parseError(err) } if err := ifi.Validate(); err != nil { @@ -619,7 +619,7 @@ func (r *Reader) parseInstructingFI() error { func (r *Reader) parseAccountCreditedDrawdown() error { r.tagName = "AccountCreditedDrawdown" creditDD := new(AccountCreditedDrawdown) - if err:= creditDD.Parse(r.line); err != nil { + if err := creditDD.Parse(r.line); err != nil { return r.parseError(err) } if err := creditDD.Validate(); err != nil { @@ -632,7 +632,7 @@ func (r *Reader) parseAccountCreditedDrawdown() error { func (r *Reader) parseOriginatorToBeneficiary() error { r.tagName = "OriginatorToBeneficiary" ob := new(OriginatorToBeneficiary) - if err:= ob.Parse(r.line); err != nil { + if err := ob.Parse(r.line); err != nil { return r.parseError(err) } if err := ob.Validate(); err != nil { @@ -645,7 +645,7 @@ func (r *Reader) parseOriginatorToBeneficiary() error { func (r *Reader) parseFIReceiverFI() error { r.tagName = "FIReceiverFI" firfi := new(FIReceiverFI) - if err:= firfi.Parse(r.line); err != nil { + if err := firfi.Parse(r.line); err != nil { return r.parseError(err) } if err := firfi.Validate(); err != nil { @@ -669,7 +669,9 @@ func (r *Reader) parseFIDrawdownDebitAccountAdvice() error { func (r *Reader) parseFIIntermediaryFI() error { r.tagName = "FIIntermediaryFI" fiifi := new(FIIntermediaryFI) - fiifi.Parse(r.line) + if err := fiifi.Parse(r.line); err != nil { + return r.parseError(err) + } if err := fiifi.Validate(); err != nil { return r.parseError(err) } @@ -691,7 +693,9 @@ func (r *Reader) parseFIIntermediaryFIAdvice() error { func (r *Reader) parseFIBeneficiaryFI() error { r.tagName = "FIBeneficiaryFI" fibfi := new(FIBeneficiaryFI) - fibfi.Parse(r.line) + if err := fibfi.Parse(r.line); err != nil { + return r.parseError(err) + } if err := fibfi.Validate(); err != nil { return r.parseError(err) } @@ -713,7 +717,9 @@ func (r *Reader) parseFIBeneficiaryFIAdvice() error { func (r *Reader) parseFIBeneficiary() error { r.tagName = "FIBeneficiary" fib := new(FIBeneficiary) - fib.Parse(r.line) + if err := fib.Parse(r.line); err != nil { + return r.parseError(err) + } if err := fib.Validate(); err != nil { return r.parseError(err) } @@ -743,10 +749,12 @@ func (r *Reader) parseFIPaymentMethodToBeneficiary() error { return nil } -func (r *Reader) parseFIAdditionalFiToFi() error { +func (r *Reader) parseFIAdditionalFIToFI() error { r.tagName = "FIAdditionalFiToFi" fifi := new(FIAdditionalFIToFI) - fifi.Parse(r.line) + if err := fifi.Parse(r.line); err != nil { + return r.parseError(err) + } if err := fifi.Validate(); err != nil { return r.parseError(err) } diff --git a/receiverDepositoryInstitution_test.go b/receiverDepositoryInstitution_test.go index a8a1df0b..eb738623 100644 --- a/receiverDepositoryInstitution_test.go +++ b/receiverDepositoryInstitution_test.go @@ -102,4 +102,4 @@ func TestParseReceiverReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/senderDepositoryInstitution_test.go b/senderDepositoryInstitution_test.go index 91e6f93a..d085e86a 100644 --- a/senderDepositoryInstitution_test.go +++ b/senderDepositoryInstitution_test.go @@ -102,4 +102,4 @@ func TestParseSenderReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/senderReference_test.go b/senderReference_test.go index afcfb1c8..83539b81 100644 --- a/senderReference_test.go +++ b/senderReference_test.go @@ -68,4 +68,4 @@ func TestParseSenderReferenceReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/senderSupplied_test.go b/senderSupplied_test.go index 0d18c6ae..f6b583f0 100644 --- a/senderSupplied_test.go +++ b/senderSupplied_test.go @@ -113,4 +113,4 @@ func TestParseSenderSuppliedReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +} diff --git a/test/testdata/fedWireMessage-CustomerTransferPlus.txt b/test/testdata/fedWireMessage-CustomerTransferPlus.txt index 4279203d..f2732ea2 100644 --- a/test/testdata/fedWireMessage-CustomerTransferPlus.txt +++ b/test/testdata/fedWireMessage-CustomerTransferPlus.txt @@ -28,5 +28,5 @@ {6400}Line One Line Two Line Three Line Four Line Five Line Six {6410}LTRLine One Line Two Line Three Line Four Line Five Line Six {6420}CHECKAdditional Information -{6500}Line One Line Two Line Three Line Four Line Five Line Six Remittance Free Text Line Two Remittance Free Text Line Three +{6500}Line One Line Two Line Three Line Four Line Five Line Six {9000}Line One Line Two Line Three Line Four Line Five Line Five Line Six Line Seven Line Eight Line Nine Line Ten Line Eleven line Twelve \ No newline at end of file diff --git a/typeSubType_test.go b/typeSubType_test.go index 7ec743eb..39afd692 100644 --- a/typeSubType_test.go +++ b/typeSubType_test.go @@ -102,4 +102,4 @@ func TestParseTypeSubTypeReaderParseError(t *testing.T) { t.Errorf("%T: %s", err, err) } } -} \ No newline at end of file +}