소스 검색

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

Julien Voisin 6 달 전
부모
커밋
473c9f225e
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  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 {
 func validateListChoices(inputValues, choices []string) error {
 	for _, value := range inputValues {
 	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
 	return nil