mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +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.
|
||||
* If $params[0] is true, it also check for string == true.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
@ -637,20 +637,6 @@ class ValidateTest extends BaseTestCase
|
||||
$v->rule('boolean', 'test');
|
||||
$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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user