com.nls.validation.WhitelistValidator Maven / Gradle / Ivy
package com.nls.validation;
import com.nls.util.Emails;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.List;
public class WhitelistValidator implements ConstraintValidator {
public void initialize(Whitelist parameters) {
}
public boolean isValid(String object, ConstraintValidatorContext context) {
List emails = Emails.asList(object);
for (String email : emails) {
if (!Emails.validDomainOrEmail(email)) {
return false;
}
}
return true;
}
}