diff --git a/src/Validation/Validator.php b/src/Validation/Validator.php index 713175029ba..fe46fff03c8 100644 --- a/src/Validation/Validator.php +++ b/src/Validation/Validator.php @@ -1607,6 +1607,7 @@ public function integer($field, $message = null, $when = null) * @param string|null $message The error message when the rule fails. * @param string|callable|null $when Either 'create' or 'update' or a callable that returns * true when the validation rule should be applied. + * @see \Cake\Validation\Validation::isArray() * @return $this */ public function isArray($field, $message = null, $when = null) @@ -1625,13 +1626,14 @@ public function isArray($field, $message = null, $when = null) * @param string|null $message The error message when the rule fails. * @param string|callable|null $when Either 'create' or 'update' or a callable that returns * true when the validation rule should be applied. + * @see \Cake\Validation\Validation::isScalar() * @return $this */ - public function isScalar($field, $message = null, $when = null) + public function scalar($field, $message = null, $when = null) { $extra = array_filter(['on' => $when, 'message' => $message]); - return $this->add($field, 'isScalar', $extra + [ + return $this->add($field, 'scalar', $extra + [ 'rule' => 'isScalar' ]); } diff --git a/tests/TestCase/Validation/ValidatorTest.php b/tests/TestCase/Validation/ValidatorTest.php index 2353cd61c7d..13c15d3ff20 100644 --- a/tests/TestCase/Validation/ValidatorTest.php +++ b/tests/TestCase/Validation/ValidatorTest.php @@ -1801,14 +1801,14 @@ public function testIsArray() } /** - * Tests the isScalar proxy method + * Tests the scalar proxy method * * @return void */ - public function testIsScalar() + public function testScalar() { $validator = new Validator(); - $validator->isScalar('username'); + $validator->scalar('username'); $this->assertEmpty($validator->errors(['username' => 'scalar'])); $this->assertNotEmpty($validator->errors(['username' => ['array']])); }