Hi,

What's the status of Zend_Filter::isEmail() ?

I've created some supposedly RFC 2822 compliant validation function
based on http://www.ilovejackdaniels.com/php/email-address-validation/ :


    /**
     * Returns value if it is a valid email format, FALSE otherwise.
     *
     * @param mixed $value
     * @return mixed
     */
    public static function isEmail($value)
    {
        // First make sure we have all parts, and in right lengths
        if (! preg_match("/[EMAIL PROTECTED],[EMAIL PROTECTED]@]{1,255}$/", 
$value))
            return false;

        // Split address into local part and domain part
        list($local, $domain) = explode('@', $value);

        // Check local part
        if (!
preg_match('/^[\w!#$%&\'*+-\/=?^`{|}~"]([\w!#$%&\'*+-\/=?^`{|}~."]|\\\\
)*$/', $local)) return false;
        
        // Check domain part
        if (! self::isHostname($domain, self::HOST_ALLOW_ALL))
            return false;
        
        return $value;
    }

but I'm not sure it works.

You're welcome to test it, maybe we can get that (so needed) method
already ;)

Shahar.

Reply via email to