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:
20
common.go
20
common.go
@ -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
|
||||
|
Reference in New Issue
Block a user