package uk.ac.ebi.quickgo.common.validator;

import java.util.Arrays;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Gene product IDs that don't match the regular expressions for recognised/supported gene product types should be
 * rejected with an error; those that do match should be treated as valid (plausible), even if they don't actually
 * identify a gene product in any of the supported databases.
 * The supported databases should be: UniProtKB, RNAcentral, IntAct, and any of the databases that are available in
 * the ID mapping function.
 *
 * @author Tony Wardell
 * Date: 14/06/2016
 * Time: 13:32
 * Created with IntelliJ IDEA.
 */
public class GeneProductIDValidator implements ConstraintValidator<GeneProductIDList, String> {
    private static final String MESSAGE = "At least one 'Gene Product ID' value is invalid: %s";

    @Autowired
    DbXRefEntityValidation xRefFormats;
    private Predicate<String> idValidator;

    @Override public void initialize(GeneProductIDList constraintAnnotation) {
        idValidator = xRefFormats::test;
    }

    @Override public boolean isValid(String s, ConstraintValidatorContext context) {
        if (s == null) {
            return true;
        }
        String invalid = Arrays.stream(s.split(",")).filter(idValidator.negate()).collect
                (Collectors.joining(", "));

        if(invalid != null && invalid.isEmpty()){
            return true;
        }
        context.disableDefaultConstraintViolation();
        context.buildConstraintViolationWithTemplate(String.format(MESSAGE, invalid))
                .addConstraintViolation();

        return false;
    }
}

@@ -926,16 +926,18 @@
 , String
+%5B%5D
 %3E %7B%0A    
@@ -1299,17 +1299,30 @@
 d(String
- 
+%5B%5D geneProduct
 s, Const
@@ -1366,16 +1366,27 @@
     if (
+geneProduct
 s == nul
@@ -1468,20 +1468,20 @@
 eam(
-s.split(%22,%22)
+geneProducts
 ).fi

Modify GeneProductIDValidator to take in an array of strings instead of a CSV value.