mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-31 07:01:54 +00:00
Removed silly string = true check
This commit is contained in:
parent
da56650a52
commit
66d62dd96d
@ -432,18 +432,13 @@ class Validator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that a field contains a boolean.
|
* Validate that a field contains a boolean.
|
||||||
* If $params[0] is true, it also check for string == true.
|
|
||||||
*
|
*
|
||||||
* @param string $field
|
* @param string $field
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param array $params
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function validateBoolean($field, $value, $params)
|
protected function validateBoolean($field, $value)
|
||||||
{
|
{
|
||||||
if(isset($params[0]) && $params[0] == true && $value == "true") {
|
|
||||||
$value = true;
|
|
||||||
}
|
|
||||||
return (is_bool($value)) ? true : false;
|
return (is_bool($value)) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -637,20 +637,6 @@ class ValidateTest extends BaseTestCase
|
|||||||
$v->rule('boolean', 'test');
|
$v->rule('boolean', 'test');
|
||||||
$this->assertFalse($v->validate());
|
$this->assertFalse($v->validate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBooleanStringValid()
|
|
||||||
{
|
|
||||||
$v = new Validator(array('test' => "true"));
|
|
||||||
$v->rule('boolean', 'test', true);
|
|
||||||
$this->assertTrue($v->validate());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testBooleanStringInvalid()
|
|
||||||
{
|
|
||||||
$v = new Validator(array('test' => 'notrue'));
|
|
||||||
$v->rule('boolean', 'test', true);
|
|
||||||
$this->assertFalse($v->validate());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sampleFunctionCallback($field, $value, array $params) {
|
function sampleFunctionCallback($field, $value, array $params) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user