Issues

ZF-9649: Zend_Validate_PostCode and Zend_Validate_CreditCard, call the method _setValue after of validated a input in method isValid

Issue Type: Improvement Created: 2010-04-11T09:29:40.000+0000 Last Updated: 2010-04-11T11:18:15.000+0000 Status: Resolved Fix version(s): - 1.10.4 (28/Apr/10)

Reporter: Ramon Henrique Ornelas (ramon) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:

Description

Most validators has the behavior: The input value :>isValue($value), is only assigned :>value after being validated.

Zend_Validate_PostCode and Zend_Validate_CreditCard, hurt this behavior, in method isValid().

Example current code:

<pre class="highlight">
$this->_setValue($value);
if (!is_string($value)) {
    $this->_error(self::INVALID);
    return false;
}

I think what should be:

<pre class="highlight">
if (!is_string($value)) {
    $this->_error(self::INVALID);
    return false;
}
$this->_setValue($value);

Comments

Posted by Thomas Weidner (thomas) on 2010-04-11T10:36:14.000+0000

Closing as non-issue.

There is no such rule.

The value has to be set BEFORE it is being used within an error message. And this is done within all validators.

Posted by Ramon Henrique Ornelas (ramon) on 2010-04-11T11:18:14.000+0000

@Thomas Most validators has this behavior.

Example:

<pre class="highlight">
$validate = new Zend_Validate_Barcode($options);
$validate->isValid(new stdClass());
$validate->value; // returns null

In PostCode and CreditCard:

<pre class="highlight">
$validate = new Zend_Validate_PostCode($options);
$validate->isValid(new stdClass());
$validate->value; // returns object stdClass

What would be the correct?

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