mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
closes #3303 RFC: Rename Validator::between() into Validator::length()
This commit is contained in:
parent
d0b995ad79
commit
4848b63189
6 changed files with 14 additions and 14 deletions
|
@ -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')
|
||||
* )
|
||||
* );
|
||||
* }}}
|
||||
|
|
|
@ -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')
|
||||
* ));
|
||||
* }}}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue