コード例 #1
0
ファイル: post.php プロジェクト: jumper9/test
 private static function validateFields($fields)
 {
     // validate fields
     $dataFields = array();
     foreach ($fields as $field) {
         if ($field["name"]) {
             if (!isset($field["type"])) {
                 $field["type"] = "string";
             }
             $validations = array();
             $validations[0] = $field["type"];
             if (isset($field["minlength"]) && $field["minlength"]) {
                 $validations[] = "minlength:{$field["minlength"]}";
             }
             if (isset($field["maxlength"]) && $field["maxlength"]) {
                 $validations[] = "maxlength:{$field["maxlength"]}";
             }
             if (isset($field["minvalue"]) && $field["minvalue"]) {
                 $validations[] = "minvalue:{$field["minvalue"]}";
             }
             if (isset($field["maxvalue"]) && $field["maxvalue"]) {
                 $validations[] = "maxvalue:{$field["maxvalue"]}";
             }
             if (!isset($field["errorMessage"])) {
                 $field["errorMessage"] = "Invalid {$field["name"]}";
             }
             f::validateParam($field["name"], $validations, $field["errorMessage"]);
             $dataFields[$field["name"]] = f::getParam($field["name"]);
         }
     }
     return $dataFields;
 }