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 @@
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. -
+ - +