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

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:


$this->_setValue($value);
if (!is_string($value)) {
    $this->_error(self::INVALID);
    return false;
}

I think what should be:


if (!is_string($value)) {
    $this->_error(self::INVALID);
    return false;
}
$this->_setValue($value);

Comments

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.

@Thomas Most validators has this behavior.

Example:


$validate = new Zend_Validate_Barcode($options);
$validate->isValid(new stdClass());
$validate->value; // returns null

In PostCode and CreditCard:


$validate = new Zend_Validate_PostCode($options);
$validate->isValid(new stdClass());
$validate->value; // returns object stdClass

What would be the correct?