I am trying to write a class that extends Zend_Validate_Abstract. Its purpose is to determine whether the date and time supplied is or at least two business days away from now, or time(). (A lot of heavy lifting there, but I am recycling/wrapping an old class that has been tested thoroughly, and works.)
I would like its isValid() method to take two arguments, a string date and string time which we will turn to a Unix timestamp with strtotime() or else throw an exception. Or it could take an array with indices 'date' and 'time', I don't care. So I studied the example at http://framework.zend.com/manual/en/zend.filter.input.html, where it says $validators = array( 'password' => array( 'StringEquals', 'fields' => array('password1', 'password2') ) ); and then shows you how to put it all together. So I try this, inside the validate() method of my model, which extends Zend_Db_Table_Row_Abstract: require('lib/validators/AdvanceNotice.php'); require('Zend/Filter/Input.php'); $validators = array( 'date' => array( new AdvanceNotice(), 'fields' =>array('date','time'), ) ); $filters = array( '*' => 'StringTrim', ); $input = new Zend_Filter_Input($filters,$validators,$this->toArray()); Now here's the part I don't get. When the input validation fails, it all works just fine. When it succeeds, however, it seems that the Zend_Filter_Input instance's isValid() calls my model's isValid() not once but three times. The first time through it passes it this array (when I use this as test input): Array ( [date] => 2007-09-13 [time] => 10:00:00 ) and the second and third times, it passes each of those strings '2007-09-13' and '10:00:00', respectively. If it would just not do that, all would be peachy-keen. Am i doing somethiing wrong or have I discovered a bug? Thought experiment: would the outcome be different if my class implemented Zend_Validate_Interface instead of extending Zend_Validate_Abstract? Thanks a million, -- David Mintz http://davidmintz.org/ The subtle source is clear and bright The tributary streams flow through the darkness
