'required|string', ]; if ($this->input('type') == 'url' || $this->input('type') == 'pdf') { $array['chatbot_data'] = 'required|array'; $array['chatbot_data.*'] = 'sometimes|nullable|integer'; } return $array; } protected function prepareForValidation(): void {} }