### 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)

"""Test Duplicate multiple connection with suffix
    when there are already 10 copies, no new copy
    should be created"""
    connection_ids = [f"test_duplicate_postgres_connection_copy{i}" for i in range(1, 11)]
    connections = [
        Connection(
            conn_id=connection_id,
            conn_type="FTP",
            description="Postgres",
            host="localhost",
            schema="airflow",
            port=3306,
        )
        for connection_id in connection_ids
    ]
    with create_session() as session:
        session.query(Connection).delete()
        session.add_all(connections)
    data = {"action": "mulduplicate", "rowid": [connections[0].id]}
    resp = admin_client.post("/connection/action_post", data=data, follow_redirects=True)
    expected_result = {f"test_duplicate_postgres_connection_copy{i}" for i in range(1, 11)}
    assert resp.status_code == 200
    response = {conn[0] for conn in session.query(Connection.conn_id).all()}
    assert expected_result == response
@pytest.fixture()
def connection():