code: func (s StreamName) Validate() error {
  	if len(s) == 0 {
  		return errors.New("must contain at least one character")
  	}
  	if len(s) > MaxStreamNameLength {
  		return fmt.Errorf("stream name is too long (%d > %d)", len(s), MaxStreamNameLength)
  	}
  
  	var lastRune rune
  	var segmentIdx int
  	for idx, r := range s {
  		// Alphanumeric.
  		if !isAlnum(r) {
  			// The stream name must begin with an alphanumeric character.
  			if idx == segmentIdx {
  				return fmt.Errorf("Segment (at %d) must begin with alphanumeric character.", segmentIdx)
  			}
  
  			// Test forward slash, and ensure no adjacent forward slashes.
  			if r == StreamNameSep {
  				segmentIdx = idx + utf8.RuneLen(r)
  			} else if !(r == '.' || r == '_' || r == '-' || r == ':') {
  				// Test remaining allowed characters.
  				return fmt.Errorf("Illegal charater (%c) at index %d.", r, idx)
  			}
  		}
  		lastRune = r
  	}
  
  	// The last rune may not be a separator.
  	if lastRune == StreamNameSep {
  		return errors.New("Name may not end with a separator.")
  	}
  	return nil
  }
docs: // Validate tests whether the stream name is valid.