@@ -130,14 +130,27 @@ public static function rules($existing = null)
130130 {
131131 $ unique = Rule::unique ('scripts ' )->ignore ($ existing );
132132
133+ if ($ existing ) {
134+ $ allowedLanguages = static ::scriptFormatValues ();
135+ $ allowedExecutorIds = ScriptExecutor::all ()->pluck ('id ' )->toArray ();
136+ } else {
137+ $ allowedLanguages = array_filter (static ::scriptFormatValues (), function ($ language ) {
138+ return !in_array ($ language , Script::deprecatedLanguages);
139+ });
140+ $ allowedExecutorIds = ScriptExecutor::active ()->pluck ('id ' )->toArray ();
141+ }
142+
133143 return [
134144 'key ' => 'unique:scripts,key ' ,
135145 'title ' => ['required ' , 'string ' , $ unique , 'alpha_spaces ' ],
136146 'language ' => [
137147 'required_without:script_executor_id ' ,
138- Rule::in (static ::scriptFormatValues ()),
148+ Rule::in ($ allowedLanguages ),
149+ ],
150+ 'script_executor_id ' => [
151+ 'required_without:language ' ,
152+ Rule::in ($ allowedExecutorIds ),
139153 ],
140- 'script_executor_id ' => 'required_without:language|exists:script_executors,id ' ,
141154 'description ' => 'required ' ,
142155 'run_as_user_id ' => 'required ' ,
143156 'timeout ' => 'integer|min:0|max:65535 ' ,
0 commit comments