MCPcopy
hub / github.com/IBM/sarama / validateGroupInstanceId

Function validateGroupInstanceId

config.go:927–941  ·  view source on GitHub ↗
(id string)

Source from the content-addressed store, hash-verified

925var GROUP_INSTANCE_ID_REGEXP = regexp.MustCompile(`^[0-9a-zA-Z\._\-]+$`)
926
927func validateGroupInstanceId(id string) error {
928 if id == "" {
929 return ConfigurationError("Group instance id must be non-empty string")
930 }
931 if id == "." || id == ".." {
932 return ConfigurationError(`Group instance id cannot be "." or ".."`)
933 }
934 if len(id) > MAX_GROUP_INSTANCE_ID_LENGTH {
935 return ConfigurationError(fmt.Sprintf(`Group instance id cannot be longer than %v, characters: %s`, MAX_GROUP_INSTANCE_ID_LENGTH, id))
936 }
937 if !GROUP_INSTANCE_ID_REGEXP.MatchString(id) {
938 return ConfigurationError(fmt.Sprintf(`Group instance id %s is illegal, it contains a character other than, '.', '_' and '-'`, id))
939 }
940 return nil
941}

Callers 2

TestValidGroupInstanceIdFunction · 0.85
ValidateMethod · 0.85

Calls 1

ConfigurationErrorTypeAlias · 0.85

Tested by 1

TestValidGroupInstanceIdFunction · 0.68