From 527c9288163a8823c2995f1b8a569f92d001e5e3 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Thu, 28 Oct 2021 09:45:02 +0200 Subject: [PATCH] fix: [API] Simplify some validations --- app/Lib/Tools/AttributeValidationTool.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/app/Lib/Tools/AttributeValidationTool.php b/app/Lib/Tools/AttributeValidationTool.php index 9449503c8..4bfb96666 100644 --- a/app/Lib/Tools/AttributeValidationTool.php +++ b/app/Lib/Tools/AttributeValidationTool.php @@ -488,10 +488,7 @@ class AttributeValidationTool return true; case 'link': // Moved to a native function whilst still enforcing the scheme as a requirement - if (filter_var($value, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) && !preg_match("#\n#", $value)) { - return true; - } - break; + return filter_var($value, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) && !preg_match("#\n#", $value); case 'hex': return ctype_xdigit($value); case 'target-user': @@ -594,20 +591,13 @@ class AttributeValidationTool case 'prtn': case 'phone-number': case 'whois-registrant-phone': - if (is_numeric($value)) { - return true; - } - break; + case 'float': + return is_numeric($value); case 'cortex': json_decode($value); return json_last_error() === JSON_ERROR_NONE; - case 'float': - return is_numeric($value); case 'boolean': - if ($value == 1 || $value == 0) { - return true; - } - break; + return $value == 1 || $value == 0; case 'AS': if (self::isPositiveInteger($value) && $value <= 4294967295) { return true;