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.
39 lines
1.1 KiB
39 lines
1.1 KiB
package pain
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type GrpHdr struct {
|
|
MessageId string `xml:"MsgId"`
|
|
Timestamp string `xml:"CreDtTm"`
|
|
NumTx string `xml:"NbOfTxs"`
|
|
Sum string `xml:"CtrlSum"`
|
|
InitiatingParty PartyIdSEPA1 `xml:"InitgPty"`
|
|
}
|
|
|
|
func (g *GrpHdr) Valid() error {
|
|
var err []string
|
|
if !SEPARegexps["MsgId"].MatchString(g.MessageId) {
|
|
err = append(err, "msgId did not match expected format")
|
|
}
|
|
if !SEPARegexps["CreDtTm"].MatchString(g.Timestamp) {
|
|
err = append(err, "timestamp did not match expected format")
|
|
}
|
|
if !SEPARegexps["NbOfTxs"].MatchString(g.NumTx) {
|
|
err = append(err, "numtx did not match expected format")
|
|
}
|
|
if !SEPARegexps["CtrlSum"].MatchString(g.Sum) {
|
|
err = append(err, "sum did not match expected format")
|
|
}
|
|
// Note: we assume g.InitiatingParty is initialized.
|
|
if !SEPARegexps["Nm"].MatchString(g.InitiatingParty.Name) {
|
|
err = append(err, "initiating party's name did not match expected format")
|
|
}
|
|
|
|
if len(err) > 0 {
|
|
return fmt.Errorf("group header not valid: %v", strings.Join(err, ", "))
|
|
}
|
|
return nil
|
|
}
|
|
|