@@ -153,8 +153,8 @@ protected function rules(): array
153153 'staticImage ' => 'required ' ,
154154 'baseDirectory ' => array_merge (['required ' ], array_slice (ValidationPatterns::directoryPathRules (), 1 )),
155155 'publishDirectory ' => ValidationPatterns::directoryPathRules (),
156- 'portsExposes ' => 'required ' ,
157- 'portsMappings ' => ' nullable ' ,
156+ 'portsExposes ' => [ 'required ' , ' string ' , ' regex:/^(\d+)(,\d+)*$/ ' ] ,
157+ 'portsMappings ' => ValidationPatterns:: portMappingRules () ,
158158 'customNetworkAliases ' => 'nullable ' ,
159159 'dockerfile ' => 'nullable ' ,
160160 'dockerRegistryImageName ' => 'nullable ' ,
@@ -209,6 +209,8 @@ protected function messages(): array
209209 'staticImage.required ' => 'The Static Image field is required. ' ,
210210 'baseDirectory.required ' => 'The Base Directory field is required. ' ,
211211 'portsExposes.required ' => 'The Exposed Ports field is required. ' ,
212+ 'portsExposes.regex ' => 'Ports exposes must be a comma-separated list of port numbers (e.g. 3000,3001). ' ,
213+ ...ValidationPatterns::portMappingMessages (),
212214 'isStatic.required ' => 'The Static setting is required. ' ,
213215 'isStatic.boolean ' => 'The Static setting must be true or false. ' ,
214216 'isSpa.required ' => 'The SPA setting is required. ' ,
@@ -752,6 +754,12 @@ public function submit($showToaster = true)
752754 $ this ->authorize ('update ' , $ this ->application );
753755
754756 $ this ->resetErrorBag ();
757+
758+ $ this ->portsExposes = str ($ this ->portsExposes )->replace (' ' , '' )->trim ()->toString ();
759+ if ($ this ->portsMappings ) {
760+ $ this ->portsMappings = str ($ this ->portsMappings )->replace (' ' , '' )->trim ()->toString ();
761+ }
762+
755763 $ this ->validate ();
756764
757765 $ oldPortsExposes = $ this ->application ->ports_exposes ;
0 commit comments