Issues

ZF-2734: Improvements for Zend_Validate_EmailAddress and Zend_Validate_HostName Integration

Issue Type: Patch Created: 2008-02-26T11:54:56.000+0000 Last Updated: 2008-12-08T14:11:51.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Rubén Moraleda (xplorastudios) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:

Description

It should be desirable that Zend_Validate_EmailAddress could propagate his current translator to the Zend_Validate_HostName prior validating it.

Also, Zend_Validate_HostName messages aren't returned with the corresponding keys, making them impossible to translate through a Zend_Form object.

I suggest change this code at Zend/Validate/EmailAddress.php from:

<pre class="highlight">
// Match hostname part
$hostnameResult = $this->hostnameValidator->isValid($this->_hostname);
if (!$hostnameResult) {
    $this->_error(self::INVALID_HOSTNAME);
    foreach ($this->hostnameValidator->getMessages() as $message) {
         $this->_messages[] = $message;
    }
    foreach ($this->hostnameValidator->getErrors() as $error) {
         $this->_errors[] = $error;
    }
}

To:

<pre class="highlight">
// Propagate current translator to the hostname validator
$this->hostnameValidator->setTranslator($this->getTranslator());
// Match hostname part
$hostnameResult = $this->hostnameValidator->isValid($this->_hostname);
if (!$hostnameResult) {
      $this->_error(self::INVALID_HOSTNAME);
       foreach ($this->hostnameValidator->getMessages() as $key=>$message) {
            $this->_messages[$key] = $message;
       }
       foreach ($this->hostnameValidator->getErrors() as $error) {
            $this->_errors[] = $error;
       }
}

Comments

Posted by Matthew Weier O'Phinney (matthew) on 2008-03-05T10:23:24.000+0000

Not a Zend_Form issue; this has to do with Zend_Validate. Assigning to Darby.

BTW, you can set a global translator for Validate objects using:

<pre class="highlight">
Zend_Validate_Abstract::setDefaultTranslator($translate);

which will correct the problem for you in the short-term.

Posted by Thomas Weidner (thomas) on 2008-12-08T14:11:50.000+0000

Already fixed in actual release. The translator is used visa-versa.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts