Here's what I plan to do, and I'd love some feedback as to whether it's
considered good practice.

class MyModel  extends Zend_Db_Table_Abstract {

   /* $_dependentTables & $_referenceMap defined here */

  protected $validationErrors;


   public function validate() {

         // all the Zend_* validation setup here

        $input = new Zend_Filter_Input($filters,$validators,$data);


        $this->validationErrors = $input->getMessages();

        return $Input->isValid();

        }
   }

   public function getValidationErrors() {
      return $this->validationErrors;
   }
}

So, in the corresponding controller...

if ($model->validate()) {

   //  save the data to db, or whatever, etc

} else {

    // put $model->getValidationErrors() in the view

}

but I am also thinking validate(), after (maybe) populating its
errorMessages field, could return $this so that a controller could say

if ($errors = $model->validate()->getValidationErrors()) {
        // ...
}

... but i guess then you'd *have* to do something like that if validate()
doesn't return a boolean. (duh).

Thoughts?

This noob appreciates your help.

-- 
David Mintz
http://davidmintz.org/

The subtle source is clear and bright
The tributary streams flow through the darkness

Reply via email to