### Description

I bumped into a bug where a connection id was suffixed with a whitespace e.g. "myconn ". When referencing the connection id "myconn" (without whitespace), you get a connection not found error.

To avoid such human errors, I suggest restricting the characters allowed for connection ids.

Some suggestions:
- There's an `airflow.utils.helpers.validate_key` function for validating the DAG id. Probably a good idea to reuse this.
- I believe variable ids are also not validated, would be good to check those too.

### Use case/motivation

_No response_

### Related issues

_No response_

### Are you willing to submit a PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

connection = Connection(
        conn_id="conn1",
        conn_type="Conn 1",
        description="Conn 1 description",
    )
    with create_session() as session:
        session.add(connection)
    yield connection
    with create_session() as session:
        session.query(Connection).filter(Connection.conn_id == CONNECTION["conn_id"]).delete()
def test_connection_muldelete(admin_client, connection):
    conn_id = connection.id
    data = {"action": "muldelete", "rowid": [conn_id]}
    resp = admin_client.post("/connection/action_post", data=data, follow_redirects=True)
    assert resp.status_code == 200
    with create_session() as session:
        assert session.query(Connection).filter(Connection.id == conn_id).count() == 0
@mock.patch("airflow.providers_manager.ProvidersManager.hooks", new_callable=PropertyMock)
def test_connection_form_widgets_testable_types(mock_pm_hooks, admin_client):