All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nls.validation.EmailListValidator Maven / Gradle / Ivy

There is a newer version: 1.0.14
Show newest version
package com.nls.validation;

import com.nls.util.Emails;
import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.List;

public class EmailListValidator implements ConstraintValidator {

    private final EmailValidator emailValidator = new EmailValidator();

    public void initialize(EmailList parameters) {
    }

    public boolean isValid(String object, ConstraintValidatorContext context) {
        List emails = Emails.asList(object);
        for (String email : emails) {
            if (!emailValidator.isValid(email, context)) {
                return false;
            }
        }
        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy