Skip to content
Permalink
Browse files

Rename Validator::isScalar() to Validator::scalar()

  • Loading branch information...
chinpei215 committed Jul 26, 2017
1 parent 60e082b commit 4fd0bc58d3b80d4a844fff15a9cefce682c02f21
Showing with 7 additions and 5 deletions.
  1. +4 −2 src/Validation/Validator.php
  2. +3 −3 tests/TestCase/Validation/ValidatorTest.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'
]);
}
@@ -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']]));
}

0 comments on commit 4fd0bc5

Please sign in to comment.
You can’t perform that action at this time.