Browse Source

Bugfixes, names, regexes, e instead of err

master
Gerdriaan Mulder 6 years ago
parent
commit
f71e2c8fa7
  1. 6
      pain/pain.go
  2. 4
      pain/pain_regexp.go
  3. 4
      pain/payment_information.go
  4. 2
      pain/payment_information_transactions.go

6
pain/pain.go

@ -24,7 +24,7 @@ func (d *Document) Valid() error {
if d.Namespace != PAIN_XMLNS { if d.Namespace != PAIN_XMLNS {
err = append(err, "xmlns does not match 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)) err = append(err, fmt.Sprintf("%v", e))
} }
@ -44,7 +44,7 @@ func (p *PainXML) Valid() error {
if e := p.GroupHeader.Valid(); e != nil { if e := p.GroupHeader.Valid(); e != nil {
err = append(err, fmt.Sprintf("%v", e)) err = append(err, fmt.Sprintf("%v", e))
} }
if len(p.PaymentInformation) < 1 { if len(p.PaymentInformation) == 0 {
err = append(err, "no payment information") err = append(err, "no payment information")
} }
for i, pi := range p.PaymentInformation { for i, pi := range p.PaymentInformation {
@ -140,7 +140,7 @@ func NewPartyIdSEPA3(id string) PartyIdSEPA3 {
} }
func (p *PartyIdSEPA3) Valid() error { func (p *PartyIdSEPA3) Valid() error {
return p.Valid() return p.PartySEPA2.Valid()
} }
type PersonIdSEPA2 struct { type PersonIdSEPA2 struct {

4
pain/pain_regexp.go

@ -6,6 +6,7 @@ import (
var ( var (
ISODateTime = regexp.MustCompile(`\d{4}(-\d\d){2}T\d\d(:\d\d){2}`) 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}`) RestrictedIdentificationSEPA1 = regexp.MustCompile(`([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|'| ]){1,35}`)
RestrictedIdentificationSEPA2 = regexp.MustCompile(`([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,35}`) RestrictedIdentificationSEPA2 = regexp.MustCompile(`([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|']){1,35}`)
Max15NumericText = regexp.MustCompile(`[0-9]{1,15}`) Max15NumericText = regexp.MustCompile(`[0-9]{1,15}`)
@ -27,6 +28,7 @@ var (
var ( var (
SEPARegexps = map[string]*regexp.Regexp{ SEPARegexps = map[string]*regexp.Regexp{
"AdrLine": Max70Text,
"BIC": BICIdentifier, "BIC": BICIdentifier,
"CreDtTm": ISODateTime, "CreDtTm": ISODateTime,
"CtrlSum": RestrictedDecimalNumber, "CtrlSum": RestrictedDecimalNumber,
@ -44,7 +46,7 @@ var (
"PmtMetaLclInstrm": LocalInstrumentSEPACode, "PmtMetaLclInstrm": LocalInstrumentSEPACode,
"PmtMetaSvcLvl": ServiceLevelSEPACode, "PmtMetaSvcLvl": ServiceLevelSEPACode,
"PmtMtd": PaymentMethod2Code, "PmtMtd": PaymentMethod2Code,
"ReqdColltnDt": ISODateTime, "ReqdColltnDt": ISODate,
"SeqTp": SequenceType1Code, "SeqTp": SequenceType1Code,
"Ustrd": Max140Text, "Ustrd": Max140Text,
} }

4
pain/payment_information.go

@ -55,7 +55,7 @@ func (pmt *PmtInf) Valid() error {
type PmtTpInf struct { type PmtTpInf struct {
ServiceLevel Code `xml:"SvcLvl"` ServiceLevel Code `xml:"SvcLvl"`
LocalInstrument Code `xml:"LclIntrm"` LocalInstrument Code `xml:"LclInstrm"`
SequenceType string `xml:"SeqTp"` SequenceType string `xml:"SeqTp"`
} }
@ -107,7 +107,7 @@ func (p *PstlAdr) Valid() error {
} }
type CdtrAgt struct { type CdtrAgt struct {
InstitutionId FinInstnId `xml:"FinInstId"` InstitutionId FinInstnId `xml:"FinInstnId"`
} }
func (c *CdtrAgt) Valid() error { func (c *CdtrAgt) Valid() error {

2
pain/payment_information_transactions.go

@ -115,7 +115,7 @@ func (d *DrctDbtTx) Valid() error {
} }
type DbtrAgt struct { type DbtrAgt struct {
InstitutionId FinInstnId `xml:"FinInstId"` InstitutionId FinInstnId `xml:"FinInstnId"`
} }
func (d *DbtrAgt) Valid() error { func (d *DbtrAgt) Valid() error {

Loading…
Cancel
Save