─── Segment validators ─────────────────────────────────────────────────────── validateProviderToken validates a provider token per the ABNF grammar.
(token string)
| 229 | |
| 230 | // validateProviderToken validates a provider token per the ABNF grammar. |
| 231 | func 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. |
| 251 | func validateModelToken(token string) error { |
no test coverage detected