names.go 635 B

123456789101112
  1. package utils
  2. import "regexp"
  3. // RestrictedNameChars collects the characters allowed to represent a name, normally used to validate container and volume names.
  4. const RestrictedNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.-]`
  5. // RestrictedNamePattern is a regular expression to validate names against the collection of restricted characters.
  6. var RestrictedNamePattern = regexp.MustCompile(`^/?` + RestrictedNameChars + `+$`)
  7. // RestrictedVolumeNamePattern is a regular expression to validate volume names against the collection of restricted characters.
  8. var RestrictedVolumeNamePattern = regexp.MustCompile(`^` + RestrictedNameChars + `+$`)