First, you are even trying to use the wrong:
ORM::factory('User')->rules(array ('city_id, array (array (' not_empty '), array (' digit '))));
As a minimum, there should be as follows:
ORM::factory('User')->rules(array ('city_id => array (array (' not_empty '), array (' digit '))));
Without intervention in the code does not work, I will explain ...
In the ORM:
public function rules()
{
return array ();
}
Who we override in the model.
Even a record implies a redefinition of what is already in the model.
ORM::factory('User')->rules(array ('city_id => array (array (' not_empty '), array (' digit '))));
But neither of which you can add the required method Class ORM:
public function addRules($a2){
$a1 = $ this->rules();
return array_merge_recursive ($a1,$a2);
}
Then we get the following:
ORM::factory('User')->addRules(array ('city_id => array (array (' not_empty '), array (' digit '))));
Cool, but it does not work, as in:
/**
* Initializes validation rules, and labels
*
* @return void
*/
protected function _validation()
{
// Build the validation object with its rules
$this->_validation = Validation::factory($this->_object)
->bind(':model', $this)
->bind(':original_values', $this->_original_values)
->bind(':changed', $this->_changed);
foreach ($this->rules() as $field => $rules)
{
$this->_validation->rules($field, $rules);
}
// Use column names by default for labels
$columns = array_keys($this->_table_columns);
// Merge user-defined labels
$labels = array_merge(array_combine($columns, $columns), $this->labels());
foreach ($labels as $field => $label)
{
$this->_validation->label($field, $label);
}
}
It still causes rules()
, and this is that the model ...
You can continue the thought, but I advise you to take advantage of external validation.