route()->parameter('server'); Assert::isInstanceOf($server, Server::class); return [ 'database' => [ 'required', 'alpha_dash', 'min:1', 'max:48', // Yes, I am aware that you could have the same database name across two unique hosts. However, // I don't really care about that for this validation. We just want to make sure it is unique to // the server itself. No need for complexity. Rule::unique('databases')->where(function (Builder $query) use ($server) { $query->where('server_id', $server->id) ->where('database', DatabaseManagementService::generateUniqueDatabaseName($this->input('database'), $server->id)); }), ], 'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/', ]; } /** * @return array */ public function messages() { return [ 'database.unique' => 'The database name you have selected is already in use by this server.', ]; } }