Skip to content

Commit

Permalink
Returns nilID when id is invalid (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
robxyy authored Oct 9, 2022
1 parent 7fac693 commit 1a49bc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions id.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func (id *ID) UnmarshalText(text []byte) error {
}
}
if !decode(id, text) {
*id = nilID
return ErrInvalidID
}
return nil
Expand Down
4 changes: 4 additions & 0 deletions id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ func TestFromStringInvalid(t *testing.T) {
if err != ErrInvalidID {
t.Errorf("FromString(invalid) err=%v, want %v", err, ErrInvalidID)
}
id, err := FromString("c6e52g2mrqcjl44hf179")
if id != nilID {
t.Errorf("FromString() =%v, want %v", id, nilID)
}
}

type jsonType struct {
Expand Down

0 comments on commit 1a49bc0

Please sign in to comment.