Issues

ZF-4939: Zend_Validate gets error codes from messages keys (not from errors), Zend_Validate_EmailAddress doesnt set error keys for messages at all

Description

Following code: $validators = new Zend_Validate(); $validators->addValidator(new Zend_Validate_EmailAddress()); $validators->isValid('www@www.ww'); Zend_Debug::dump($validators->getErrors());

Returns: array(3) { ["emailAddressInvalidHostname"] => string(63) "'www.ww' is not a valid hostname for email address 'www@www.ww'" [0] => string(77) "'www.ww' appears to be a DNS hostname but cannot match TLD against known list" [1] => string(83) "'www.ww' appears to be a local network name but local network names are not allowed" }

the errors codes are missing.

The bug is in class Zend_Validate because it gets the error codes from error messages keys and not from $validator->getErrors() $messages = $validator->getMessages(); $this->_messages = array_merge($this->_messages, $messages); $this->_errors = array_merge($this->_errors, array_keys($messages));

and also in class Zend_Validate_EmailAddress: // Get messages and errors from hostnameValidator foreach ($this->hostnameValidator->getMessages() as $message) { $this->_messages[] = $message; } where the validator doesn't set the error messages keys and IMO it should look like this: // Get messages and errors from hostnameValidator foreach ($this->hostnameValidator->getMessages() as $error => $message) { $this->_messages[$error] = $message; }

Comments

Fixed with r13113