Consolidate ref checking logic for FE and BE
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=392817)
</details>
<!--IssueSummary end-->
## Background
The following discussion from !101930 should be addressed:
- [ ] @mrincon started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/101930#note_1286465452): (+1 comment)
> **Suggestion (non-blocking):** We have a very similar regex here: https://gitlab.com/gitlab-org/gitlab/blob/master/lib/api/validations/validators/git_ref.rb#L12
>
> Maybe we can use the same list or cross link these with comment?
## Problem to solve
* [ ] We should investigate how to best consolidate the regex / checks we use for `refs`:
- https://gitlab.com/gitlab-org/gitlab/blob/master/lib/api/validations/validators/git_ref.rb#L12
- https://gitlab.com/gitlab-org/gitlab/-/blob/7359d23f4e078479969c872924150219c6f1665f/app/assets/javascripts/new_branch_form.js#L41
- https://gitlab.com/gitlab-org/gitlab/-/merge_requests/101930/diffs#5816bb73a73e0d5de1bcf5674b4de4e86e1ede72_528_539
* [ ] Move related utils to a https://gitlab.com/gitlab-org/gitlab/-/merge_requests/101930#note_1286465451 (if it still makes sense)
issue