{"record":{"id":"2ad9a2d3924627a8","repo":"bcit-ci/CodeIgniter","slug":"form-validation-set-rules-called-without-a-rul","errorCode":null,"errorMessage":"Form_validation: set_rules() called without a $rules parameter","messagePattern":"Form_validation: set_rules\\(\\) called without a \\$rules parameter","errorType":"exception","errorClass":"BadMethodCallException","httpStatus":null,"severity":"error","filePath":"system/libraries/Form_validation.php","lineNumber":196,"sourceCode":"\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// If the field label wasn't passed we use the field name\n\t\t\t\t$label = isset($row['label']) ? $row['label'] : $row['field'];\n\n\t\t\t\t// Add the custom error message array\n\t\t\t\t$errors = (isset($row['errors']) && is_array($row['errors'])) ? $row['errors'] : array();\n\n\t\t\t\t// Here we go!\n\t\t\t\t$this->set_rules($row['field'], $label, $row['rules'], $errors);\n\t\t\t}\n\n\t\t\treturn $this;\n\t\t}\n\t\telseif ( ! isset($rules))\n\t\t{\n\t\t\tthrow new BadMethodCallException('Form_validation: set_rules() called without a $rules parameter');\n\t\t}\n\n\t\t// No fields or no rules? Nothing to do...\n\t\tif ( ! is_string($field) OR $field === '' OR empty($rules))\n\t\t{\n\t\t\tthrow new RuntimeException('Form_validation: set_rules() called with an empty $rules parameter');\n\t\t}\n\t\telseif ( ! is_array($rules))\n\t\t{\n\t\t\t// BC: Convert pipe-separated rules string to an array\n\t\t\tif ( ! is_string($rules))\n\t\t\t{\n\t\t\t\tthrow new InvalidArgumentException('Form_validation: set_rules() expect $rules to be string or array; '.gettype($rules).' given');\n\t\t\t}\n\n\t\t\t$rules = preg_split('/\\|(?![^\\[]*\\])/', $rules);\n\t\t}\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/bcit-ci/CodeIgniter/blob/3658d731eaabe6117298a105ffb5b9dd59e190ce/system/libraries/Form_validation.php#L178-L214","documentation":"Error \"Form_validation: set_rules() called without a $rules parameter\" thrown in bcit-ci/CodeIgniter.","triggerScenarios":"Thrown at system/libraries/Form_validation.php:196 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3658d731eaabe6117298a105ffb5b9dd59e190ce","analyzedAt":"2026-08-17T02:34:56.929Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}