示例#1
0
 public function onValidateDocument(Validation $validation, DataSource_Hybrid_Document $doc)
 {
     if ($this->min !== NULL or $this->max !== NULL) {
         $min = $this->min !== NULL ? $this->min : -99999999999;
         $max = $this->max !== NULL ? $this->max : 99999999999;
         $validation->rule($this->name, 'range', array(':value', $min, $max));
     }
     if (!empty($this->_props['regexp'])) {
         if (strpos($this->regexp, '::') !== FALSE) {
             list($class, $method) = explode('::', $this->regexp);
         } else {
             $class = 'Valid';
             $method = $this->regexp;
         }
         if (method_exists($class, $method)) {
             $validation->rule($this->name, array($class, $method));
         } else {
             $validation->rule($this->name, 'regex', array(':value', $this->regexp));
         }
     }
     return parent::onValidateDocument($validation, $doc);
 }