diff --git a/classes/Kohana/ORM.php b/classes/Kohana/ORM.php index d4348b1..4736626 100644 --- a/classes/Kohana/ORM.php +++ b/classes/Kohana/ORM.php @@ -1149,7 +1149,23 @@ protected function _load_values(array $values) */ public function rules() { - return array(); + $rules = array(); + + foreach ($this->_table_columns as $column => $params) + { + if (is_array($params) && Arr::get($params, 'type') == 'string') + { + $max_length = Arr::get($params, 'character_maximum_length'); + if ( ! is_null($max_length)) + { + $rules[$column][] = array( + 'max_length', array(':value', $max_length) + ); + } + } + } + + return $rules; } /**