src/Validator/EmailValidator.php
public function validateLocalPart($value, $send_errors=false)
    {
        // check for local part length compliance (max 64 chars.)
        $lengthValidator = new StringLengthValidator(0, 64);
        try {
            if (false===$local_length_valid = $lengthValidator->validate($value, false)) {
                if (true===$send_errors) {
                    throw new \Exception(sprintf('The local part of the email address [%s] must not be up to 64 characters!', $value));
                }
                return false;
            }
        } catch (\Exception $e) {
            throw $e;
        }

        // check for dots in local part
        // => not the first character
        if (substr($value, 0, 1)=='.') {
            if (true===$send_errors) {
                throw new \Exception(sprintf('The local part of the email address [%s] must not begin with a dot!', $value));
            }
            return false;
        }
        // => not the last character
        if (substr($value, -1, 1)=='.') {
            if (true===$send_errors) {
                throw new \Exception(sprintf('The local part of the email address [%s] must not end with a dot!', $value));
            }
            return false;
        }
        // => no double-dots
        if (false!==strpos($value, '..')) {
            if (true===$send_errors) {
                throw new \Exception(sprintf('The local part of the email address [%s] must not contain double-dots!', $value));
            }
            return false;
        }

        // the local part must match the standards as wanted
        $last=0;
        foreach (self::$standards_list as $standard) {
            if (1===$last) {
                continue;
            }
            if ($standard==$this->must_pass) {
                $last=1;
            }

            $maskValidator = new StringMaskValidator(
                '^' . $this->getMask($standard) . '$', $standard
            );
            try {
                if (false===$local_part_mask_valid = $maskValidator->validate($value, $send_errors)) {
                    return false;
                }
            } catch (\Exception $e) {
                throw $e;
            }
        }

        return true;
    }
public function validateLocalPart($value, $send_errors=false)
    {
        // check for local part length compliance (max 64 chars.)
        $lengthValidator = new StringLengthValidator(0, 64);
        try {
            if (false===$local_length_valid = $lengthValidator->validate($value, false)) {
                if (true===$send_errors) {
                    throw new \Exception(sprintf('The local part of the email address [%s] must not be up to 64 characters!', $value));
                }
                return false;
            }
        } catch (\Exception $e) {
            throw $e;
        }

        // check for dots in local part
        // => not the first character
        if (substr($value, 0, 1)=='.') {
            if (true===$send_errors) {
                throw new \Exception(sprintf('The local part of the email address [%s] must not begin with a dot!', $value));
            }
            return false;
        }
        // => not the last character
        if (substr($value, -1, 1)=='.') {
            if (true===$send_errors) {
                throw new \Exception(sprintf('The local part of the email address [%s] must not end with a dot!', $value));
            }
            return false;
        }
        // => no double-dots
        if (false!==strpos($value, '..')) {
            if (true===$send_errors) {
                throw new \Exception(sprintf('The local part of the email address [%s] must not contain double-dots!', $value));
            }
            return false;
        }

        // the local part must match the standards as wanted
        $last=0;
        foreach (self::$standards_list as $standard) {
            if (1===$last) {
                continue;
            }
            if ($standard==$this->must_pass) {
                $last=1;
            }

            $maskValidator = new StringMaskValidator(
                '^' . $this->getMask($standard) . '$', $standard
            );
            try {
                if (false===$local_part_mask_valid = $maskValidator->validate($value, $send_errors)) {
                    return false;
                }
            } catch (\Exception $e) {
                throw $e;
            }
        }

        return true;
    }
public function validateLocalPart ( $ value , $ send_errors = false ) { // check for local part length compliance (max 64 chars.) $ lengthValidator = new StringLengthValidator ( 0 , 64 ) ; try { if ( false === $ local_length_valid = $ lengthValidator -> validate ( $ value , false ) ) { if ( true === $ send_errors ) { throw new \ Exception ( sprintf ( 'The local part of the email address [%s] must not be up to 64 characters!' , $ value ) ) ; } return false ; } } catch ( \ Exception $ e ) { throw $ e ; } // check for dots in local part // => not the first character if ( substr ( $ value , 0 , 1 ) == '.' ) { if ( true === $ send_errors ) { throw new \ Exception ( sprintf ( 'The local part of the email address [%s] must not begin with a dot!' , $ value ) ) ; } return false ; } // => not the last character if ( substr ( $ value , - 1 , 1 ) == '.' ) { if ( true === $ send_errors ) { throw new \ Exception ( sprintf ( 'The local part of the email address [%s] must not end with a dot!' , $ value ) ) ; } return false ; } // => no double-dots if ( false !== strpos ( $ value , '..' ) ) { if ( true === $ send_errors ) { throw new \ Exception ( sprintf ( 'The local part of the email address [%s] must not contain double-dots!' , $ value ) ) ; } return false ; } // the local part must match the standards as wanted $ last = 0 ; foreach ( self :: $ standards_list as $ standard ) { if ( 1 === $ last ) { continue ; } if ( $ standard == $ this -> must_pass ) { $ last = 1 ; } $ maskValidator = new StringMaskValidator ( '^' . $ this -> getMask ( $ standard ) . '$' , $ standard ) ; try { if ( false === $ local_part_mask_valid = $ maskValidator -> validate ( $ value , $ send_errors ) ) { return false ; } } catch ( \ Exception $ e ) { throw $ e ; } } return true ; }
Process local part validation

@param   string  $value          The local part of an email address to validate
@param   bool    $send_errors    Does the function must throw exceptions on validation failures ?
@return  bool    TRUE if `$value` pass the Email validation
@throws  \Exception for each invalid part if `$send_errors` is true
Process local part validation