mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-12-26 23:02:29 -05:00
Don't require UIDs to be 36 characters
The spec strongly recommends this, but doesn't strictly require it
This commit is contained in:
parent
1d8ba5c19a
commit
5596cfbf8d
@ -21,9 +21,7 @@ func (r *StatementRequest) Name() string {
|
||||
}
|
||||
|
||||
func (r *StatementRequest) Valid() (bool, error) {
|
||||
if ok, err := r.TrnUID.Valid(); !ok {
|
||||
return false, err
|
||||
}
|
||||
// TODO implement
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,7 @@ func (r *CCStatementRequest) Name() string {
|
||||
}
|
||||
|
||||
func (r *CCStatementRequest) Valid() (bool, error) {
|
||||
if ok, err := r.TrnUID.Valid(); !ok {
|
||||
return false, err
|
||||
}
|
||||
// TODO implement
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,7 @@ func (r *InvStatementRequest) Name() string {
|
||||
}
|
||||
|
||||
func (r *InvStatementRequest) Valid() (bool, error) {
|
||||
if ok, err := r.TrnUID.Valid(); !ok {
|
||||
return false, err
|
||||
}
|
||||
// TODO implement
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,7 @@ func (r *ProfileRequest) Name() string {
|
||||
}
|
||||
|
||||
func (r *ProfileRequest) Valid() (bool, error) {
|
||||
if ok, err := r.TrnUID.Valid(); !ok {
|
||||
return false, err
|
||||
}
|
||||
// TODO implement
|
||||
r.ClientRouting = "NONE"
|
||||
return true, nil
|
||||
}
|
||||
|
@ -32,9 +32,7 @@ func (r *SecListRequest) Name() string {
|
||||
}
|
||||
|
||||
func (r *SecListRequest) Valid() (bool, error) {
|
||||
if ok, err := r.TrnUID.Valid(); !ok {
|
||||
return false, err
|
||||
}
|
||||
// TODO implement
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@ -51,9 +49,7 @@ func (r SecListResponse) Name() string {
|
||||
}
|
||||
|
||||
func (r SecListResponse) Valid() (bool, error) {
|
||||
if ok, err := r.TrnUID.Valid(); !ok {
|
||||
return false, err
|
||||
}
|
||||
// TODO implement
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
@ -47,11 +47,6 @@ func (r *SignonRequest) Valid() (bool, error) {
|
||||
if len(r.AppVer) < 1 || len(r.AppVer) > 4 {
|
||||
return false, errors.New("SONRQ>APPVER invalid length")
|
||||
}
|
||||
if ok, err := r.ClientUID.Valid(); !ok {
|
||||
if len(r.ClientUID) > 0 { // ClientUID isn't required
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,7 @@ func (r *AcctInfoRequest) Name() string {
|
||||
}
|
||||
|
||||
func (r *AcctInfoRequest) Valid() (bool, error) {
|
||||
if ok, err := r.TrnUID.Valid(); !ok {
|
||||
return false, err
|
||||
}
|
||||
// TODO implement
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
4
types.go
4
types.go
@ -216,7 +216,9 @@ func (ob *Boolean) String() string {
|
||||
|
||||
type UID string
|
||||
|
||||
func (ou UID) Valid() (bool, error) {
|
||||
// The OFX specification recommends that UIDs follow the standard UUID
|
||||
// 36-character format
|
||||
func (ou UID) RecommendedFormat() (bool, error) {
|
||||
if len(ou) != 36 {
|
||||
return false, errors.New("UID not 36 characters long")
|
||||
}
|
||||
|
@ -276,21 +276,21 @@ func TestUnmarshalUID(t *testing.T) {
|
||||
unmarshalHelper(t, "d1cf3d3d-9ef9-4a97-b180-81706829cb04", &u, &overwritten)
|
||||
}
|
||||
|
||||
func TestUIDValid(t *testing.T) {
|
||||
func TestUIDRecommendedFormat(t *testing.T) {
|
||||
var u ofxgo.UID = "d1cf3d3d-9ef9-4a97-b180-81706829cb04"
|
||||
if ok, err := u.Valid(); !ok || err != nil {
|
||||
if ok, err := u.RecommendedFormat(); !ok || err != nil {
|
||||
t.Fatalf("UID unexpectedly failed validation\n")
|
||||
}
|
||||
u = "d1cf3d3d-9ef9-4a97-b180-81706829cb0"
|
||||
if ok, err := u.Valid(); ok || err == nil {
|
||||
if ok, err := u.RecommendedFormat(); ok || err == nil {
|
||||
t.Fatalf("UID should have failed validation because it's too short\n")
|
||||
}
|
||||
u = "d1cf3d3d-9ef94a97-b180-81706829cb04"
|
||||
if ok, err := u.Valid(); ok || err == nil {
|
||||
if ok, err := u.RecommendedFormat(); ok || err == nil {
|
||||
t.Fatalf("UID should have failed validation because it's missing hyphens\n")
|
||||
}
|
||||
u = "d1cf3d3d-9ef9-4a97-b180981706829cb04"
|
||||
if ok, err := u.Valid(); ok || err == nil {
|
||||
if ok, err := u.RecommendedFormat(); ok || err == nil {
|
||||
t.Fatalf("UID should have failed validation because its hyphens have been replaced\n")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user