Skip to content

Commit

Permalink
Allow for numbers in value descriptors
Browse files Browse the repository at this point in the history
They generate valid Go so no need to include them in the camel case
  • Loading branch information
alethenorio committed Jul 10, 2020
1 parent 7fca08f commit d5c93bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/identifiers/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ package identifiers
import "unicode"

func IsCamelCase(s string) bool {
for i, r := range s {
i := 0
for _, r := range s {
if unicode.IsDigit(r) {
continue
}
if i == 0 && !unicode.IsUpper(r) || !IsAlphaChar(r) && !IsNumChar(r) {
return false
}
i++
}
return true
}
2 changes: 2 additions & 0 deletions internal/identifiers/case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ func TestIsCamelCase(t *testing.T) {
assert.Assert(t, IsCamelCase("SOC"))
assert.Assert(t, IsCamelCase("Camel"))
assert.Assert(t, IsCamelCase("CamelCase"))
assert.Assert(t, IsCamelCase("111CamelCaseNr"))
assert.Assert(t, !IsCamelCase("camelCase"))
assert.Assert(t, !IsCamelCase("snake_case"))
assert.Assert(t, !IsCamelCase("kebab-case"))
assert.Assert(t, !IsCamelCase("111camelCaseNr"))
}

0 comments on commit d5c93bd

Please sign in to comment.