fix(validation): allow protocol suffix in port mappings (/tcp, /udp, /sctp)

This commit is contained in:
ShadowArcanist 2026-04-11 17:47:34 +05:30
parent 0d8a95473a
commit 8d84e171b6
No known key found for this signature in database

View file

@ -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).',
];
}