Skip to content

Commit

Permalink
Rename Validator::isScalar() to Validator::scalar()
Browse files Browse the repository at this point in the history
  • Loading branch information
chinpei215 committed Jul 26, 2017
1 parent 60e082b commit 4fd0bc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/Validation/Validator.php
Expand Up @@ -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)
Expand All @@ -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'
]);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Validation/ValidatorTest.php
Expand Up @@ -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']]));
}
Expand Down

0 comments on commit 4fd0bc5

Please sign in to comment.