parseIDConfig converts raw viper id data into a typed IDConfig. Returns nil if raw is nil or not a map.
(raw any)
| 266 | // parseIDConfig converts raw viper id data into a typed IDConfig. |
| 267 | // Returns nil if raw is nil or not a map. |
| 268 | func parseIDConfig(raw any) *validator.IDConfig { |
| 269 | if raw == nil { |
| 270 | return nil |
| 271 | } |
| 272 | m, ok := raw.(map[string]any) |
| 273 | if !ok { |
| 274 | return nil |
| 275 | } |
| 276 | |
| 277 | cfg := &validator.IDConfig{} |
| 278 | |
| 279 | if s, ok := m["strategy"].(string); ok { |
| 280 | cfg.Strategy = s |
| 281 | } |
| 282 | if s, ok := m["prefix"].(string); ok { |
| 283 | cfg.Prefix = s |
| 284 | } |
| 285 | cfg.Length = toInt(m["length"]) |
| 286 | cfg.Padding = toInt(m["padding"]) |
| 287 | |
| 288 | return cfg |
| 289 | } |
| 290 | |
| 291 | // parsePhasesConfig converts raw viper phases data into typed PhaseConfig entries. |
| 292 | func parsePhasesConfig(raw any) []validator.PhaseConfig { |