Issues

ZF-7673: Zend_Validate_Regex uses incorrect message template

Issue Type: Bug Created: 2009-08-24T09:36:13.000+0000 Last Updated: 2009-08-30T02:42:02.000+0000 Status: Resolved Fix version(s): - 1.9.2 (25/Aug/09)

Reporter: Hovhannes Babayan (hbabayan) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:

Description

h4. Code to reproduce error In the output of the code fragment below is visible that Zend_Validate_Regex uses Zend_Validate_Regex::INVALID message template, instead of Zend_Validate_Regex::NOT_MATCH template.

<pre class="highlight">
$validator = new Zend_Validate_Regex('/^\d+$/');
if(!$validator->isValid('this is not digit'))
{
    foreach($validator->getMessages() as $message)
    {
        $message_template = $validator->getMessageTemplates();
        $message_template = $message_template[Zend_Validate_Regex::NOT_MATCH];
        
        echo $message_template;
        echo "\n<br></br>";
        echo $message;
    }
}

h4. The cause $this->_error() call (at line 120) in Zend_Validate_Regex::isValid function uses first available message template, which in this case is Zend_Validate_Regex::INVALID.


h4. The solution: in Zend_Validate_Regex::isValid function instead of lines (119-122), just before last return statement

<pre class="highlight">
if (!$status) {
    $this->_error();
    return false;
}

should be

<pre class="highlight">
if (!$status) {
    $this->_error(self::NOT_MATCH);
    return false;
}

Comments

Posted by Thomas Weidner (thomas) on 2009-08-30T02:41:57.000+0000

This is a duplication of an existing issue and has already been fixed with ZF 1.9.2

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