diff --git a/docs/classes/validation.html b/docs/classes/validation.html index 2a64bc64..26596a2b 100644 --- a/docs/classes/validation.html +++ b/docs/classes/validation.html @@ -345,14 +345,14 @@

Error messages

Extending Validation class

There are few aproaches to extend the validation class:

- +

1. To extend the core class like described in the Extending Core Classes

- +

2. To create a class in app/classes/myvalidation.php (for example)

// app/classes/myvalidation.php
 class Myvalidation {
-    
-    public function _validation_unique($val, $options)
+
+    public function _validation_unique($val, $options, $object)
     {
         list($table, $field) = explode('.', $options);
 
@@ -360,6 +360,8 @@ 

Extending Validation class

->where("$field", '=', MBSTRING ? mb_strtolower($val) : strtolower($val)) ->from($table)->execute(); + $object->set_message('unique', 'The field :label must have an unique value.'); + if($result->count() > 0) return false; else @@ -373,17 +375,17 @@

Extending Validation class

$val->add_callable('myvalidation'); // here we add the class to load rules from $val->add_field('username', 'Your username', 'trim|strip_tags|required|unique[users.username]');
- +

3. Calling callbacks from a model. It works like a method described above, but we only need to call it in other way:

$val = Validation::factory();
 $val->add_model('Model_User');
- -

- Note: + +

+ Note: You need the '_validation_' prefix for a method to be used in validation. -

+

- +

All methods

@@ -400,4 +402,4 @@

All methods

- \ No newline at end of file + diff --git a/fuel/core/classes/validation.php b/fuel/core/classes/validation.php index 4b26b296..947e7b7f 100644 --- a/fuel/core/classes/validation.php +++ b/fuel/core/classes/validation.php @@ -228,7 +228,7 @@ public function run($input = null, $allow_partial = false) foreach ($field->rules as $rule) { $callback = $rule[0]; - $params = $rule[1]; + $params = empty($rule[1]) ? array(null) : $rule[1]; $this->_run_rule($callback, $value, $params, $field); }