1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2025-07-01 11:48:38 -04:00

Add validation of banking requests and responses

This commit is contained in:
2017-04-18 19:46:23 -04:00
parent 7f2ca5db0f
commit 1ee7197340
4 changed files with 211 additions and 3 deletions

View File

@ -274,6 +274,19 @@ type BankAcct struct {
AcctKey String `xml:"ACCTKEY,omitempty"` // Unused in USA
}
func (b BankAcct) Valid() (bool, error) {
if len(b.BankID) == 0 {
return false, errors.New("BankAcct.BankID empty")
}
if len(b.AcctID) == 0 {
return false, errors.New("BankAcct.AcctID empty")
}
if !b.AcctType.Valid() {
return false, errors.New("Invalid or unspecified BankAcct.AcctType")
}
return true, nil
}
// CCAcct represents the identifying information for one checking account
type CCAcct struct {
XMLName xml.Name // CCACCTTO or CCACCTFROM
@ -281,6 +294,13 @@ type CCAcct struct {
AcctKey String `xml:"ACCTKEY,omitempty"` // Unused in USA
}
func (c CCAcct) Valid() (bool, error) {
if len(c.AcctID) == 0 {
return false, errors.New("CCAcct.AcctID empty")
}
return true, nil
}
// InvAcct represents the identifying information for one investment account
type InvAcct struct {
XMLName xml.Name // INVACCTTO or INVACCTFROM