2 changed files with 38 additions and 0 deletions
@ -0,0 +1,36 @@ |
|||||
|
package pain |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
type DrctDbtTxInf struct { |
||||
|
Id PaymentId `xml:"PmtId"` |
||||
|
Amount CurrencyWithAmount `xml:"InstdAmt"` |
||||
|
} |
||||
|
|
||||
|
type CurrencyWithAmount struct { |
||||
|
Currency string `xml:"Ccy,attr"` |
||||
|
Value string `xml:",innerxml"` |
||||
|
} |
||||
|
|
||||
|
type PaymentId struct { |
||||
|
InstrumentId string `xml:"InstrId"` |
||||
|
EndToEndId string `xml:"EndToEndId"` |
||||
|
} |
||||
|
|
||||
|
func (p *PaymentId) Valid() error { |
||||
|
var err []string |
||||
|
if !SEPARegexps["InstrId"].MatchString(p.InstrumentId) { |
||||
|
err = append(err, "instrument id does not match format") |
||||
|
} |
||||
|
if !SEPARegexps["EndToEndId"].MatchString(p.EndToEndId) { |
||||
|
err = append(err, "end-to-end id does not match format") |
||||
|
} |
||||
|
|
||||
|
if len(err) > 0 { |
||||
|
return fmt.Errorf("payment id not valid: %v", strings.Join(err, ", ")) |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
Loading…
Reference in new issue