Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: logdog/common/types/streamaddr.go

Issue 2899953002: [logdog/common/types] add Valid method to StreamAddr. (Closed)
Patch Set: add IsZero Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/common/types/streamaddr.go
diff --git a/logdog/common/types/streamaddr.go b/logdog/common/types/streamaddr.go
index ac17da1f9bd8ae94219f9efe2c1bf965aa6f22ee..f952ff1bd4ffbaf419c2421935561cef70cc1a44 100644
--- a/logdog/common/types/streamaddr.go
+++ b/logdog/common/types/streamaddr.go
@@ -39,6 +39,25 @@ func (s *StreamAddr) Set(v string) error {
return nil
}
+// Validate returns an error if the supplied StreamAddr is not valid.
+func (s *StreamAddr) Validate() error {
+ if s.Host == "" {
+ return errors.New("cannot have empty Host")
+ }
+ if err := s.Project.Validate(); err != nil {
+ return err
+ }
+ if err := s.Path.Validate(); err != nil {
+ return err
+ }
+ return nil
+}
+
+// IsZero returns true iff all fields are empty.
+func (s *StreamAddr) IsZero() bool {
+ return s.Host == "" && s.Path == "" && s.Project == ""
+}
+
// String returns a string representation of this address.
func (s *StreamAddr) String() string { return s.URL().String() }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698