From d9bee210d48fd3ab4cd4b784c30ea534276fe1a7 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Mon, 24 Feb 2025 14:47:23 +0200 Subject: [PATCH] Adds 'ip' to validator --- app/classes/validator.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/classes/validator.php b/app/classes/validator.php index cf6717c..d9da755 100644 --- a/app/classes/validator.php +++ b/app/classes/validator.php @@ -74,6 +74,14 @@ class Validator { $this->addError($field, "Does not match $parameter field"); } break; + case 'ip': + if (!empty($value)) { + // Support both IPv4 and IPv6 + if (!filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) { + $this->addError($field, "Invalid IP address format"); + } + } + break; } }