checkIDConfig validates the id config section.
(config *ConfigData, result *ValidationResult)
| 386 | |
| 387 | // checkIDConfig validates the id config section. |
| 388 | func (v *Validator) checkIDConfig(config *ConfigData, result *ValidationResult) { |
| 389 | if config.ID == nil { |
| 390 | return |
| 391 | } |
| 392 | id := config.ID |
| 393 | |
| 394 | if id.Strategy != "" && !validIDStrategies[id.Strategy] { |
| 395 | result.AddIssue(LevelError, "", config.ConfigPath, |
| 396 | fmt.Sprintf("invalid id strategy: '%s' (valid values: sequential, prefixed, random, ulid)", id.Strategy)) |
| 397 | } |
| 398 | |
| 399 | if id.Strategy == "prefixed" && id.Prefix == "" { |
| 400 | result.AddIssue(LevelError, "", config.ConfigPath, |
| 401 | "id strategy 'prefixed' requires a non-empty prefix") |
| 402 | } |
| 403 | |
| 404 | if id.Length < 0 { |
| 405 | result.AddIssue(LevelError, "", config.ConfigPath, |
| 406 | fmt.Sprintf("id length must not be negative, got %d", id.Length)) |
| 407 | } |
| 408 | |
| 409 | if id.Padding < 0 { |
| 410 | result.AddIssue(LevelError, "", config.ConfigPath, |
| 411 | fmt.Sprintf("id padding must not be negative, got %d", id.Padding)) |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | // checkPhaseConfig validates phase entries for structural issues and duplicates. |
| 416 | func (v *Validator) checkPhaseConfig(config *ConfigData, result *ValidationResult) { |
no test coverage detected