Example #1
0
 /**
  * 	method:	validate_array
  *
  * 	todo: write documentation
  */
 protected function validate_array($name, $value, $required, $options)
 {
     $error = false;
     if (!isset($options["type"])) {
         $error = "ARRAY_REQUIRE_TYPE_PARAM";
     }
     if (!is_array($value)) {
         $error = "ARRAY_INVALID";
     }
     if ($error === false) {
         $arrayValidator = new self($value);
         foreach ($value as $k => $v) {
             $arrayValidator->add($k, $options["type"], $required, $options);
         }
         $data = array("success" => $arrayValidator->execute(), "valid" => $arrayValidator->getValid(), "errors" => $arrayValidator->getErrors());
         if (!isset($options["optimise"]) || !$options["optimise"]) {
             $data = $data["valid"];
         }
     }
     if ($required == true && $error !== false) {
         return $error;
     }
     if ($error === false) {
         $this->setValid($name, $data);
     }
     return true;
 }