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

if fieldname is None:
            fieldname = "other_field"
        validator = validators.GreaterEqualThan(fieldname=fieldname, message=message)
        return validator(self.form_mock, self.form_field_mock)
    def test_field_not_found(self):
        with pytest.raises(validators.ValidationError, match="^Invalid field name 'some'.$"):
            self._validate(
                fieldname="some",
            )
    def test_form_field_is_none(self):
        self.form_field_mock.data = None
        assert self._validate() is None
    def test_other_field_is_none(self):