From 4848b6318962e2c1b4d6897a2222a0e393a0d3f0 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Tue, 13 May 2014 09:31:03 +0200 Subject: [PATCH] closes #3303 RFC: Rename Validator::between() into Validator::length() --- lib/Cake/Model/Model.php | 10 +++++----- lib/Cake/Model/ModelValidator.php | 2 +- lib/Cake/Model/Validator/CakeValidationSet.php | 2 +- lib/Cake/Test/Case/Model/ModelValidationTest.php | 2 +- lib/Cake/Test/Case/Utility/ValidationTest.php | 10 +++++----- lib/Cake/Utility/Validation.php | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 2b6840943..ef305e107 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -142,8 +142,8 @@ class Model extends Object implements CakeEventListener { * * {{{ * public $validate = array( - * 'age' => array( - * 'rule' => array('between', 5, 25) + * 'length' => array( + * 'rule' => array('lengthBetween', 5, 25) * ) * ); * }}} @@ -171,9 +171,9 @@ class Model extends Object implements CakeEventListener { * * {{{ * public $validate = array( - * 'age' => array( - * 'rule' => array('between', 5, 25), - * 'message' => array('The age must be between %d and %d.') + * 'length' => array( + * 'rule' => array('lengthBetween', 5, 15), + * 'message' => array('Between %d to %d characters') * ) * ); * }}} diff --git a/lib/Cake/Model/ModelValidator.php b/lib/Cake/Model/ModelValidator.php index d61ba8b66..377866aa9 100644 --- a/lib/Cake/Model/ModelValidator.php +++ b/lib/Cake/Model/ModelValidator.php @@ -539,7 +539,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable { * ->add('user_id', 'valid', array('rule' => 'numeric', 'message' => 'Invalid User')) * * $validator->add('password', array( - * 'size' => array('rule' => array('between', 8, 20)), + * 'size' => array('rule' => array('lengthBetween', 8, 20)), * 'hasSpecialCharacter' => array('rule' => 'validateSpecialchar', 'message' => 'not valid') * )); * }}} diff --git a/lib/Cake/Model/Validator/CakeValidationSet.php b/lib/Cake/Model/Validator/CakeValidationSet.php index 80b9a79cc..e6817e50c 100644 --- a/lib/Cake/Model/Validator/CakeValidationSet.php +++ b/lib/Cake/Model/Validator/CakeValidationSet.php @@ -186,7 +186,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable { * {{{ * $set * ->setRule('required', array('rule' => 'notEmpty', 'required' => true)) - * ->setRule('inRange', array('rule' => array('between', 4, 10)) + * ->setRule('between', array('rule' => array('lengthBetween', 4, 10)) * }}} * * @param string $name The name under which the rule should be set diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 8a3d266fd..75d015fcf 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -767,7 +767,7 @@ class ModelValidationTest extends BaseModelTest { 'last' => false ), 'between' => array( - 'rule' => array('between', 5, 15), + 'rule' => array('lengthBetween', 5, 15), 'message' => array('You may enter up to %s chars (minimum is %s chars)', 14, 6) ) ) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 245217d2a..e4db17c2e 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -208,12 +208,12 @@ class ValidationTest extends CakeTestCase { * @return void */ public function testBetween() { - $this->assertTrue(Validation::between('abcdefg', 1, 7)); - $this->assertTrue(Validation::between('', 0, 7)); - $this->assertTrue(Validation::between('אกあアꀀ豈', 1, 7)); + $this->assertTrue(Validation::lengthBetween('abcdefg', 1, 7)); + $this->assertTrue(Validation::lengthBetween('', 0, 7)); + $this->assertTrue(Validation::lengthBetween('אกあアꀀ豈', 1, 7)); - $this->assertFalse(Validation::between('abcdefg', 1, 6)); - $this->assertFalse(Validation::between('ÆΔΩЖÇ', 1, 3)); + $this->assertFalse(Validation::lengthBetween('abcdefg', 1, 6)); + $this->assertFalse(Validation::lengthBetween('ÆΔΩЖÇ', 1, 3)); } /** diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index a2d08bb65..5930e7f8a 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -104,7 +104,7 @@ class Validation { * @param integer $max Maximum value in range (inclusive) * @return boolean Success */ - public static function between($check, $min, $max) { + public static function lengthBetween($check, $min, $max) { $length = mb_strlen($check); return ($length >= $min && $length <= $max); }