bcit-ci/CodeIgniter · error · InvalidArgumentException
Form_validation: set_rules() expect $rules to be string or a
Error message
Form_validation: set_rules() expect $rules to be string or array; $type given
What it means
Error "Form_validation: set_rules() expect $rules to be string or array; $type given" thrown in bcit-ci/CodeIgniter.
Source
Thrown at system/libraries/Form_validation.php:209
return $this;
}
elseif ( ! isset($rules))
{
throw new BadMethodCallException('Form_validation: set_rules() called without a $rules parameter');
}
// No fields or no rules? Nothing to do...
if ( ! is_string($field) OR $field === '' OR empty($rules))
{
throw new RuntimeException('Form_validation: set_rules() called with an empty $rules parameter');
}
elseif ( ! is_array($rules))
{
// BC: Convert pipe-separated rules string to an array
if ( ! is_string($rules))
{
throw new InvalidArgumentException('Form_validation: set_rules() expect $rules to be string or array; '.gettype($rules).' given');
}
$rules = preg_split('/\|(?![^\[]*\])/', $rules);
}
// If the field label wasn't passed we use the field name
$label = ($label === '') ? $field : $label;
$indexes = array();
// Is the field name an array? If it is an array, we break it apart
// into its components so that we can fetch the corresponding POST data later
if (($is_array = (bool) preg_match_all('/\[(.*?)\]/', $field, $matches)) === TRUE)
{
sscanf($field, '%[^[][', $indexes[0]);
for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
{View on GitHub (pinned to 3658d731ea)
When it happens
Trigger: Thrown at system/libraries/Form_validation.php:209 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bcit-ci/CodeIgniter@3658d731ea (2026-08-17).
Data as JSON: /api/errors/f01bea9fe35d7baf.
Report an issue: GitHub.