You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
773 B
36 lines
773 B
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
|
|
}
|
|
|