Navigation Menu

Skip to content

Commit

Permalink
improve kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
loeffel-io committed Mar 17, 2020
1 parent 099c82a commit e6b8885
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rule_kebabcase.go
Expand Up @@ -29,10 +29,10 @@ func (rule *RuleKebabCase) SetParameters(params []string) error {
}

// Validate checks if string is kebab case
// false if rune is no lowercase letter or -
// false if rune is no lowercase letter, digit or -
func (rule *RuleKebabCase) Validate(value string) (bool, error) {
for _, c := range value {
if c == 45 { // -
if c == 45 || unicode.IsDigit(c) { // 45 => -
continue
}

Expand Down
3 changes: 3 additions & 0 deletions rule_kebabcase_test.go
Expand Up @@ -14,6 +14,9 @@ func TestRuleKebabCase(t *testing.T) {
{value: "KEBABCASE", expected: false, err: nil},
{value: "kebab-case", expected: true, err: nil},
{value: "kebab-case-test", expected: true, err: nil},
{value: "kebab-123-test", expected: true, err: nil},
{value: "kebab.test", expected: false, err: nil},
{value: "kebab_test", expected: false, err: nil},
}

var i = 0
Expand Down

0 comments on commit e6b8885

Please sign in to comment.