Gotcha: Zend_Validate_StringLength interface changes between versions 1.9 and 1.10

Just a little note to myself for when i upgrade to Zend Framework 1.10

The interface to the _constructor of Zend_Validate_StringLength seems to have changed between version 1.9 and 1.10.

Zend Framework < 1.10

The constructor expects two args, min and max.

Zend Framework = 1.10

The constructor expects one argument, an array (’min’=>int, ‘max’=>int)

————

I must admit i have only done mild investgation at the moment, but look into the code when the time comes to upgrade

Compare the introductory code examples at:

version 1.9 :

http://framework.zend.com/manual/1.9/en/zend.validate.introduction.html#zend.validate.introduction.messages
and

version 1.10 :

http://framework.zend.com/manual/1.10/en/zend.validate.introduction.html#zend.validate.introduction.messages

Unfortunately the specific docs onĀ  Zend_Validate_StringLength do not seem to mention this:

http://framework.zend.com/manual/1.10/en/zend.validate.set.html#zend.validate.set.string_length

This, i guess, is a prime example of why it is good to keep framework code out of your model and use wrappers instead

public static function createStringSpec($allowedLengthArray)
{
/**

WARNING Zend 1.9.8 the interface changes for Zend_Validate_StringLength 1.10
in 1.10 use new Zend_Validate_StringLength(array('min'=>0, 'max'=>255));

**/

$mySpec = new MypLib_Specs_MySpecAdaptorZF(
new Zend_Validate_StringLength(
$allowedLengthArray['min'],
$allowedLengthArray['max']));
return $mySpec;
}

One Response to “Gotcha: Zend_Validate_StringLength interface changes between versions 1.9 and 1.10”

  1. liviu Says:

    this helped me too

Leave a Reply