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

Function validateBareName

pkg/workflow/model_identifier.go:283–298  ·  view source on GitHub ↗

validateBareName validates a bare identifier name per the ABNF grammar.

(name string)

Source from the content-addressed store, hash-verified

281
282// validateBareName validates a bare identifier name per the ABNF grammar.
283func validateBareName(name string) error {
284 if name == "" {
285 return errors.New("model identifier: bare name must not be empty (segment type: alias)")
286 }
287 // Must not start with "-" or ".".
288 if name[0] == '-' || name[0] == '.' {
289 return fmt.Errorf("model identifier: bare name %q must not start with '-' or '.' (segment type: alias)", name)
290 }
291 if !reBareName.MatchString(name) {
292 if r := firstForbiddenCharInBareName(name); r != 0 {
293 return fmt.Errorf("model identifier: character %q is not allowed in bare name %q (segment type: alias)", r, name)
294 }
295 return fmt.Errorf("model identifier: bare name %q is syntactically invalid (segment type: alias)", name)
296 }
297 return nil
298}
299
300// ─── Parameter parsing ────────────────────────────────────────────────────────
301

Callers 1

ParseModelIdentifierFunction · 0.85

Calls 2

ErrorfMethod · 0.45

Tested by

no test coverage detected