From f71e2c8fa72a59bf68e8770189f2b62e6295e22f Mon Sep 17 00:00:00 2001 From: Gerdriaan Mulder Date: Thu, 23 Jan 2020 23:22:33 +0100 Subject: [PATCH] Bugfixes, names, regexes, e instead of err --- pain/pain.go | 6 +++--- pain/pain_regexp.go | 4 +++- pain/payment_information.go | 4 ++-- pain/payment_information_transactions.go | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pain/pain.go b/pain/pain.go index bbdd705..f4f1755 100644 --- a/pain/pain.go +++ b/pain/pain.go @@ -24,7 +24,7 @@ func (d *Document) Valid() error { if d.Namespace != PAIN_XMLNS { err = append(err, "xmlns does not match PAIN_XMLNS") } - if e := d.Contents.Valid(); err != nil { + if e := d.Contents.Valid(); e != nil { err = append(err, fmt.Sprintf("%v", e)) } @@ -44,7 +44,7 @@ func (p *PainXML) Valid() error { if e := p.GroupHeader.Valid(); e != nil { err = append(err, fmt.Sprintf("%v", e)) } - if len(p.PaymentInformation) < 1 { + if len(p.PaymentInformation) == 0 { err = append(err, "no payment information") } for i, pi := range p.PaymentInformation { @@ -140,7 +140,7 @@ func NewPartyIdSEPA3(id string) PartyIdSEPA3 { } func (p *PartyIdSEPA3) Valid() error { - return p.Valid() + return p.PartySEPA2.Valid() } type PersonIdSEPA2 struct { diff --git a/pain/pain_regexp.go b/pain/pain_regexp.go index 2441658..7d53e80 100644 --- a/pain/pain_regexp.go +++ b/pain/pain_regexp.go @@ -6,6 +6,7 @@ import ( var ( ISODateTime = regexp.MustCompile(`\d{4}(-\d\d){2}T\d\d(:\d\d){2}`) + ISODate = regexp.MustCompile(`\d{4}(-\d\d){2}`) RestrictedIdentificationSEPA1 = regexp.MustCompile(`([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|'| ]){1,35}`) RestrictedIdentificationSEPA2 = regexp.MustCompile(`([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,35}`) Max15NumericText = regexp.MustCompile(`[0-9]{1,15}`) @@ -27,6 +28,7 @@ var ( var ( SEPARegexps = map[string]*regexp.Regexp{ + "AdrLine": Max70Text, "BIC": BICIdentifier, "CreDtTm": ISODateTime, "CtrlSum": RestrictedDecimalNumber, @@ -44,7 +46,7 @@ var ( "PmtMetaLclInstrm": LocalInstrumentSEPACode, "PmtMetaSvcLvl": ServiceLevelSEPACode, "PmtMtd": PaymentMethod2Code, - "ReqdColltnDt": ISODateTime, + "ReqdColltnDt": ISODate, "SeqTp": SequenceType1Code, "Ustrd": Max140Text, } diff --git a/pain/payment_information.go b/pain/payment_information.go index 4943476..d07d6fd 100644 --- a/pain/payment_information.go +++ b/pain/payment_information.go @@ -55,7 +55,7 @@ func (pmt *PmtInf) Valid() error { type PmtTpInf struct { ServiceLevel Code `xml:"SvcLvl"` - LocalInstrument Code `xml:"LclIntrm"` + LocalInstrument Code `xml:"LclInstrm"` SequenceType string `xml:"SeqTp"` } @@ -107,7 +107,7 @@ func (p *PstlAdr) Valid() error { } type CdtrAgt struct { - InstitutionId FinInstnId `xml:"FinInstId"` + InstitutionId FinInstnId `xml:"FinInstnId"` } func (c *CdtrAgt) Valid() error { diff --git a/pain/payment_information_transactions.go b/pain/payment_information_transactions.go index 74c98cd..7349fb2 100644 --- a/pain/payment_information_transactions.go +++ b/pain/payment_information_transactions.go @@ -115,7 +115,7 @@ func (d *DrctDbtTx) Valid() error { } type DbtrAgt struct { - InstitutionId FinInstnId `xml:"FinInstId"` + InstitutionId FinInstnId `xml:"FinInstnId"` } func (d *DbtrAgt) Valid() error {