From 8d84e171b617ecf6b171c4ec810f4bd33285fdce Mon Sep 17 00:00:00 2001 From: ShadowArcanist <162910371+ShadowArcanist@users.noreply.github.com> Date: Sat, 11 Apr 2026 17:47:34 +0530 Subject: [PATCH] fix(validation): allow protocol suffix in port mappings (/tcp, /udp, /sctp) --- app/Support/ValidationPatterns.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Support/ValidationPatterns.php b/app/Support/ValidationPatterns.php index 15d0f19e0..339299692 100644 --- a/app/Support/ValidationPatterns.php +++ b/app/Support/ValidationPatterns.php @@ -203,10 +203,11 @@ public static function volumeNameMessages(string $field = 'name'): array } /** - * Pattern for port mappings (e.g. 3000:3000, 8080:80, 8000-8010:8000-8010) + * Pattern for port mappings (e.g. 3000:3000, 8080:80/udp, 8000-8010:8000-8010) * Each entry requires host:container format, where each side can be a number or a range (number-number) + * with an optional protocol suffix (/tcp, /udp, /sctp) on either or both sides */ - public const PORT_MAPPINGS_PATTERN = '/^(\d+(-\d+)?:\d+(-\d+)?)(,\d+(-\d+)?:\d+(-\d+)?)*$/'; + public const PORT_MAPPINGS_PATTERN = '/^(\d+(-\d+)?(\/(?:tcp|udp|sctp))?:\d+(-\d+)?(\/(?:tcp|udp|sctp))?)(,\d+(-\d+)?(\/(?:tcp|udp|sctp))?:\d+(-\d+)?(\/(?:tcp|udp|sctp))?)*$/'; /** * Get validation rules for container name fields @@ -230,7 +231,7 @@ public static function portMappingRules(): array public static function portMappingMessages(string $field = 'portsMappings'): array { return [ - "{$field}.regex" => 'Port mappings must be a comma-separated list of port pairs or ranges (e.g. 3000:3000,8080:80,8000-8010:8000-8010).', + "{$field}.regex" => 'Port mappings must be a comma-separated list of port pairs or ranges with optional protocol (e.g. 3000:3000,8080:80/udp,8000-8010:8000-8010).', ]; }