phalcon/cphalcon · error · Phalcon\Filter\Validation\Exceptions\NoValidators
There are no validators to validate
Error message
There are no validators to validate
What it means
validate() begins by reading $this->validators and requires it to be an array. NoValidators ('There are no validators to validate') is thrown when that property is NOT an array — the property is initialized to [] and setValidators() is typed array, so in practice this means something corrupted or replaced the protected property (a subclass assigning null/false, or an unserialize artifact).
Source
Thrown at phalcon/Filter/Validation.zep:629
* $validation->validate($_POST, $entity, $fields);
* ```
*
* @param array|object $data the data that needs to be validated
* @param object $entity the entity object to assign data to
* @param array $whitelist only allow these fields to be mutated when entity is used
*
* @return Messages|false
*/
public function validate(var data = null, var entity = null, array whitelist = []) -> <Messages> | bool
{
var combinedFieldsValidators, field, scope, status, validator,
validatorData, validators, inputData = null;
let validatorData = this->validators,
combinedFieldsValidators = this->combinedFieldsValidators;
if unlikely typeof validatorData != "array" {
throw new NoValidators();
}
/**
* Clear pre-calculated values
*/
let this->values = [];
/**
* Implicitly creates a Phalcon\Messages\Messages object
*/
let this->messages = new Messages();
if (data !== null) {
// if data is provided
if unlikely typeof data != "array" && typeof data != "object" {
throw new InvalidValidationData();
}
let this->data = data;
let inputData = data;View on GitHub (pinned to b7419de9cd)
Solutions
- Never overwrite $validators with a non-array — build it with add(), rule(), rules(), or setValidators(array)
- In subclasses, call parent::__construct() and mutate via the public API
- If the object comes from cache/session, rebuild the validation instead of unserializing a corrupted copy
- An empty validator set is legal ([]); no special case is needed for 'no rules'
Example fix
// before
class MyValidation extends Validation
{
public function __construct()
{
$this->validators = null; // later validate() throws NoValidators
}
}
// after
class MyValidation extends Validation
{
public function __construct()
{
parent::__construct();
$this->rule('email', new Email());
}
} Defensive patterns
Strategy: validation
Validate before calling
if (!is_array($validation->getValidators())) {
throw new RuntimeException('Validation validator map corrupted: rebuild the object instead of reusing it');
}
$messages = $validation->validate($data); Try / catch
use Phalcon\Filter\Validation\Exceptions\NoValidators;
try {
$messages = $v->validate($data);
} catch (NoValidators $e) {
$v->setValidators($this->buildRuleSet()); // rebuild from a known-good source
$messages = $v->validate($data);
} Prevention
- Never assign non-arrays to validators/combinedFieldsValidators in subclasses — use add()/setValidators()
- Do not unserialize validation objects from cache; rebuild them from definitions
- Add a guard in custom constructors that any inherited properties stay arrays
When it happens
Trigger: A custom subclass of Validation whose constructor or hook does $this->validators = null; state restored from a broken serialization where the array was lost; legacy code assigning a non-array copied from old tutorials.
Common situations: Extending Phalcon\Filter\Validation and redeclaring/overwriting $validators without keeping it an array; object caching/session serialization of validation objects that dropped the property.
Related errors
- The validator scope is not valid
- Unable to insert into {table} without data
- The number of values in the update is not the same as fields
- RETURNING requires at least one column or '*'
- Field must be passed as array of fields or string
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/34bdb97241075860.
Report an issue: GitHub.