From eca3896bfc76293f86f2fd6e768343a747530a75 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 8 Jan 2020 16:03:26 +0200 Subject: [PATCH] Improve array of bools filtering --- system/blueprints/user/account.yaml | 1 + system/blueprints/user/group.yaml | 1 + system/src/Grav/Common/Data/Validation.php | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/system/blueprints/user/account.yaml b/system/blueprints/user/account.yaml index b5cde9bcd..b48e79007 100644 --- a/system/blueprints/user/account.yaml +++ b/system/blueprints/user/account.yaml @@ -126,3 +126,4 @@ form: ignore_empty: true validate: type: array + value_type: bool diff --git a/system/blueprints/user/group.yaml b/system/blueprints/user/group.yaml index ddb7d242c..3ab07546f 100644 --- a/system/blueprints/user/group.yaml +++ b/system/blueprints/user/group.yaml @@ -45,3 +45,4 @@ form: ignore_empty: true validate: type: array + value_type: bool diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index 30666dbf9..2764067fa 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -720,7 +720,13 @@ class Validation if ($type && $val !== '' && $val !== null) { switch ($type) { case 'bool': - $val = Utils::isPositive($val); + if (Utils::isPositive($val)) { + $val = true; + } elseif (Utils::isNegative($val)) { + $val = false; + } else { + $val = null; + } break; case 'int': $val = (int)$val;