appuio / cloud-portal

APPUiO Cloud Portal (Web Frontend)
Apache License 2.0
5 stars 0 forks source link

Strip white spaces from start and end of user input #556

Closed corvus-ch closed 10 months ago

corvus-ch commented 11 months ago

Description

Whites aces from the beginning and the end of user input, should be removed.

Additional Context

This should be asserted on the API side but is not (https://ticket.vshn.net/browse/APUB-501). Before we change this, we would like the frontend to mitigate this up.

Logs

apiVersion: appuio.io/v1
kind: OrganizationMembers
metadata:
  […]
spec:
  userRefs:
  - name: ' ytelezhkin1'
  - name: dwestfield2
  - name: 'hekkel7 '
  - name: 'rdumbara'  
  […]

Expected Behavior

White spaces from the start and the beginning and end of user input should be removed.

apiVersion: appuio.io/v1
kind: OrganizationMembers
metadata:
  […]
spec:
  userRefs:
  - name: 'ytelezhkin1'
  - name: dwestfield2
  - name: 'hekkel7'
  - name: 'rdumbara'  
  […]

Steps To Reproduce

Entering data with a white space at the front and or the end.

steffinchen commented 10 months ago

@corvus-ch Should leading/trailing whitespaces automatically be removed, or the form field marked as invalid (and submitting not allowed)? I can see pro/cons for either: automatically removing them makes it easier for the user as they don't have to think about it, however can lead to confusion if they, for some reason, want a trailing whitespace, and it just disappears.

corvus-ch commented 10 months ago

Some values must be RFC 1123 and RFC 1035 compliant where leading and trailing are invalid. For the remaining values, having leading/trailing white spaces is confusing at best. So, I err on the side of just strait remove them.