MCPcopy
hub / github.com/google/ax / validateID

Function validateID

internal/controller/validation.go:27–41  ·  view source on GitHub ↗

validateID checks if an ID contains allowed characters and is not reserved.

(id string)

Source from the content-addressed store, hash-verified

25
26// validateID checks if an ID contains allowed characters and is not reserved.
27func 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}

Callers 5

TestValidateIDFunction · 0.85
RegisterATEMethod · 0.85
RegisterLocalMethod · 0.85
RegisterRemoteMethod · 0.85
RegisterColabMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestValidateIDFunction · 0.68