Skip to content

Commit b1015f6

Browse files
committed
fix: split key_prefix validation into two separate validators
Per review by @deiga: use two StringMatch validators inside validation.All() — one for allowed characters (^[a-zA-Z0-9.=+:/#_-]+$) and one for the digit-suffix check (\D$) — instead of a single combined regex. This makes the error messages more precise.
1 parent c3b0efd commit b1015f6

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

github/resource_github_repository_autolink_reference.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,15 @@ func resourceGithubRepositoryAutolinkReference() *schema.Resource {
6969
Required: true,
7070
ForceNew: true,
7171
Description: "This prefix appended by a number will generate a link any time it is found in an issue, pull request, or commit",
72-
ValidateDiagFunc: validation.ToDiagFunc(validation.StringMatch(
73-
regexp.MustCompile(`^[a-zA-Z0-9.=+:/#_-]*[a-zA-Z.=+:/#_-]$`),
74-
"must only contain letters, numbers, or .-_+=:/# and must not end with a number",
72+
ValidateDiagFunc: validation.ToDiagFunc(validation.All(
73+
validation.StringMatch(
74+
regexp.MustCompile(`^[a-zA-Z0-9.=+:/#_-]+$`),
75+
"must only contain letters, numbers, or the characters .-_+=:/#",
76+
),
77+
validation.StringMatch(
78+
regexp.MustCompile(`\D$`),
79+
"must not end with a number",
80+
),
7581
)),
7682
},
7783
"target_url_template": {

0 commit comments

Comments
 (0)