From a1b4f44be48e4475182455ca5ec90b90d713b875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 20 Dec 2022 12:10:37 +0000 Subject: [PATCH] Fix boolean validator --- src/Validator/Boolean.php | 8 -------- tests/Validator/BooleanTest.php | 8 ++++---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Validator/Boolean.php b/src/Validator/Boolean.php index 50c1c986..beb75a9c 100644 --- a/src/Validator/Boolean.php +++ b/src/Validator/Boolean.php @@ -77,14 +77,6 @@ public function isValid($value): bool return true; } - if ($this->loose && ($value === '1' || $value === '0')) { // Accept numeric strings - return true; - } - - if ($this->loose && ($value === 1 || $value === 0)) { // Accept integers - return true; - } - if (\is_bool($value)) { return true; } diff --git a/tests/Validator/BooleanTest.php b/tests/Validator/BooleanTest.php index b1742918..8b62a5aa 100755 --- a/tests/Validator/BooleanTest.php +++ b/tests/Validator/BooleanTest.php @@ -33,10 +33,10 @@ public function testCanValidateLoosely() $this->assertTrue($boolean->isValid(false)); $this->assertTrue($boolean->isValid('false')); $this->assertTrue($boolean->isValid('true')); - $this->assertTrue($boolean->isValid('0')); - $this->assertTrue($boolean->isValid('1')); - $this->assertTrue($boolean->isValid(0)); - $this->assertTrue($boolean->isValid(1)); + $this->assertFalse($boolean->isValid('0')); + $this->assertFalse($boolean->isValid('1')); + $this->assertFalse($boolean->isValid(0)); + $this->assertFalse($boolean->isValid(1)); $this->assertFalse($boolean->isValid(['string', 'string'])); $this->assertFalse($boolean->isValid('string')); $this->assertFalse($boolean->isValid(1.2));