Example #1
0
 function validate($data)
 {
     $results = array();
     $errors = array();
     // very simple if we're required and not present, fail
     // otherwise, its ok.
     $val = KTUtil::arrayGet($data, $this->sInputVariable);
     if ($this->bTrim) {
         $val = trim($val);
     }
     $l = KTUtil::utf8_strlen($val);
     if ($l < $this->iMinLength) {
         $errors[$this->sBasename] = $this->sMinLengthWarning;
     } else {
         if ($l > $this->iMaxLength) {
             $errors[$this->sBasename] = $this->sMaxLengthWarning;
         }
     }
     if ($this->bProduceOutput) {
         $results[$this->sOutputVariable] = $val;
     }
     return array('errors' => $errors, 'results' => $results);
 }