validateBareName validates a bare identifier name per the ABNF grammar.
(name string)
| 281 | |
| 282 | // validateBareName validates a bare identifier name per the ABNF grammar. |
| 283 | func 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 |
no test coverage detected