MCPcopy Create free account
hub / github.com/github/gh-aw / validateProviderToken

Function validateProviderToken

pkg/workflow/model_identifier.go:231–248  ·  view source on GitHub ↗

─── Segment validators ─────────────────────────────────────────────────────── validateProviderToken validates a provider token per the ABNF grammar.

(token string)

Source from the content-addressed store, hash-verified

229
230// validateProviderToken validates a provider token per the ABNF grammar.
231func validateProviderToken(token string) error {
232 if token == "" {
233 return errors.New("model identifier: provider token must not be empty (segment type: provider)")
234 }
235 if !reProviderToken.MatchString(token) {
236 if r := firstForbiddenCharInProviderOrParam(token); r != 0 {
237 return fmt.Errorf("model identifier: character %q is not allowed in provider token %q (segment type: provider)", r, token)
238 }
239 if !isAlpha(rune(token[0])) {
240 return fmt.Errorf("model identifier: provider token %q must start with a letter (segment type: provider)", token)
241 }
242 }
243 // Provider token must not end with "-".
244 if strings.HasSuffix(token, "-") {
245 return fmt.Errorf("model identifier: provider token %q must not end with '-' (segment type: provider)", token)
246 }
247 return nil
248}
249
250// validateModelToken validates a model token (no wildcards) per the ABNF grammar.
251func validateModelToken(token string) error {

Callers 1

ParseModelIdentifierFunction · 0.85

Calls 3

isAlphaFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected