Skip to content

Commit

Permalink
closes #3303 RFC: Rename Validator::between() into Validator::length()
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed May 13, 2014
1 parent d0b995a commit 4848b63
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions lib/Cake/Model/Model.php
Expand Up @@ -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)
* )
* );
* }}}
Expand Down Expand Up @@ -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')
* )
* );
* }}}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/ModelValidator.php
Expand Up @@ -539,7 +539,7 @@ public function count() {
* ->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')
* ));
* }}}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Validator/CakeValidationSet.php
Expand Up @@ -186,7 +186,7 @@ public function getRules() {
* {{{
* $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
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Model/ModelValidationTest.php
Expand Up @@ -767,7 +767,7 @@ public function testValidationMessageAsArray() {
'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)
)
)
Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Test/Case/Utility/ValidationTest.php
Expand Up @@ -208,12 +208,12 @@ public function testAlphaNumericPassedAsArray() {
* @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));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Validation.php
Expand Up @@ -104,7 +104,7 @@ public static function alphaNumeric($check) {
* @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);
}
Expand Down

0 comments on commit 4848b63

Please sign in to comment.