Skip to content

Validate project and repository name before confirmation

Description

As brought up in https://gitlab.com/gitlab-org/gitlab-ce/issues/17835#note_12047395, not all characters are valid for project and repository names, but this is only communicated to the user after they try to save their changes:

If you enter something in the bottom field that violates the validation requirements, like a ", no error message is shown. If you then hit the green "Save changes", you'll see the error.

Screenshot_2018-03-20_13.11.10

If you enter an invalid character in the 'Repository name' field, you'll simply see a 500 error.

Proposal

We should validate the strings entered by the user before they hit the 'Save' button, or at least before we send the changes to the backend. We already have a pattern in our sign up form that we can use solve this problem:

2018-03-20_13.17.33

Validation for Project Name

  • Start: Must start with a letter, digit, emoji, or '_'.
  • Body: Name can contain only letters, digits, emojis, '_', '.','+', dashes, or spaces

Validation for Project Slug

  • Start: Must start with a letter or digit.
  • Body: Name can contain only letters, digits, '_', '.','+', or dashes
  • Body: Must not contain consecutive special characters
  • End: Must not end with a special character
  • End: Must not end in '.git' or '.atom'

This should happen for the Create project, Create group, Edit project and Edit group pages.

Edited by Michael Le