validateID checks if an ID contains allowed characters and is not reserved.
(id string)
| 25 | |
| 26 | // validateID checks if an ID contains allowed characters and is not reserved. |
| 27 | func validateID(id string) error { |
| 28 | if id == "" { |
| 29 | return errors.New("empty ID") |
| 30 | } |
| 31 | |
| 32 | if !validIDRegex.MatchString(id) { |
| 33 | return fmt.Errorf("invalid ID %q: must only contain A-Z, a-z, 0-9, -, and _", id) |
| 34 | } |
| 35 | |
| 36 | if _, isReserved := reservedAgentIDs[strings.ToLower(id)]; isReserved { |
| 37 | return fmt.Errorf("agent ID %q is reserved", id) |
| 38 | } |
| 39 | |
| 40 | return nil |
| 41 | } |
no outgoing calls