src/Validator/MailValidator.php
public function validateAddress($address, $field, $isRequired = true)
    {
        if ($isRequired && empty($address)) {
            $this->addError($field, sprintf('%s is empty', ucfirst($field)));
            return false;
        }

        $validator = new EmailValidator();
        $validation = new RFCValidation();

        $success = true;
        foreach ($address as $email => $label) {
            if (!is_scalar($label)) {
                $this->addError(
                    $field,
                    sprintf('Label for %s is not scalar, `%s` given', $field, gettype($label))
                );
                $label = gettype($label);
                $success = false;
            }

            if ($validator->isValid($email, $validation) == false) {
                $this->addError(
                    $field,
                    sprintf('`%s` is not a valid email address for %s `%s`', $email, $field, $label)
                );
                $success = false;
            }
        }

        return $success;
    }
public function validateAddress($address, $field, $isRequired = true)
    {
        if ($isRequired && empty($address)) {
            $this->addError($field, sprintf('%s is empty', ucfirst($field)));
            return false;
        }

        $validator = new EmailValidator();
        $validation = new RFCValidation();

        $success = true;
        foreach ($address as $email => $label) {
            if (!is_scalar($label)) {
                $this->addError(
                    $field,
                    sprintf('Label for %s is not scalar, `%s` given', $field, gettype($label))
                );
                $label = gettype($label);
                $success = false;
            }

            if ($validator->isValid($email, $validation) == false) {
                $this->addError(
                    $field,
                    sprintf('`%s` is not a valid email address for %s `%s`', $email, $field, $label)
                );
                $success = false;
            }
        }

        return $success;
    }
public function validateAddress ( $ address , $ field , $ isRequired = true ) { if ( $ isRequired && empty ( $ address ) ) { $ this -> addError ( $ field , sprintf ( '%s is empty' , ucfirst ( $ field ) ) ) ; return false ; } $ validator = new EmailValidator ( ) ; $ validation = new RFCValidation ( ) ; $ success = true ; foreach ( $ address as $ email => $ label ) { if ( ! is_scalar ( $ label ) ) { $ this -> addError ( $ field , sprintf ( 'Label for %s is not scalar, `%s` given' , $ field , gettype ( $ label ) ) ) ; $ label = gettype ( $ label ) ; $ success = false ; } if ( $ validator -> isValid ( $ email , $ validation ) == false ) { $ this -> addError ( $ field , sprintf ( '`%s` is not a valid email address for %s `%s`' , $ email , $ field , $ label ) ) ; $ success = false ; } } return $ success ; }
Validate address fields

@param array  $address
@param string $field
@param bool   $isRequired

@return bool
Validate address fields