Selaa lähdekoodia

refactor(config): reuse validateChoices in validateListChoices to avoid duplication

Julien Voisin 6 kuukautta sitten
vanhempi
commit
473c9f225e
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 2 2
      internal/config/validators.go

+ 2 - 2
internal/config/validators.go

@@ -20,8 +20,8 @@ func validateChoices(rawValue string, choices []string) error {
 
 func validateListChoices(inputValues, choices []string) error {
 	for _, value := range inputValues {
-		if !slices.Contains(choices, value) {
-			return fmt.Errorf("value must be one of: %v", strings.Join(choices, ", "))
+		if err := validateChoices(value, choices); err != nil {
+			return err
 		}
 	}
 	return nil