diff --git a/README.md b/README.md index bfc1489..cf9433c 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ type Person struct { This package currently provides the following checkers: - [alphanumeric](doc/checkers/alphanumeric.md) checks if the given string consists of only alphanumeric characters. -- [ASCII](doc/checkers/ASCII.md) checks if the given string consists of only ASCII characters. +- [ascii](doc/checkers/ascii.md) checks if the given string consists of only ASCII characters. - [cidr](doc/checkers/cidr.md) checker checks if the value is a valid CIDR notation IP address and prefix length. - [digits](doc/checkers/digits.md) checks if the given string consists of only digit characters. - [email](doc/checkers/email.md) checks if the given string is an email address. diff --git a/ascii.go b/ascii.go index d259c68..e06c171 100644 --- a/ascii.go +++ b/ascii.go @@ -6,7 +6,7 @@ import ( ) // CheckerASCII is the name of the checker. -const CheckerASCII = "ASCII" +const CheckerASCII = "ascii" // ResultNotASCII indicates that the given string contains non-ASCII characters. const ResultNotASCII = "NOT_ASCII" diff --git a/ascii_test.go b/ascii_test.go index bc5eb72..de2a9ea 100644 --- a/ascii_test.go +++ b/ascii_test.go @@ -18,7 +18,7 @@ func TestCheckASCIINonString(t *testing.T) { defer FailIfNoPanic(t) type User struct { - Age int `checkers:"ASCII"` + Age int `checkers:"ascii"` } user := &User{} @@ -28,7 +28,7 @@ func TestCheckASCIINonString(t *testing.T) { func TestCheckASCIIInvalid(t *testing.T) { type User struct { - Username string `checkers:"ASCII"` + Username string `checkers:"ascii"` } user := &User{ @@ -43,7 +43,7 @@ func TestCheckASCIIInvalid(t *testing.T) { func TestCheckASCIIValid(t *testing.T) { type User struct { - Username string `checkers:"ASCII"` + Username string `checkers:"ascii"` } user := &User{ diff --git a/checker_test.go b/checker_test.go index 8c93d88..b3e5b80 100644 --- a/checker_test.go +++ b/checker_test.go @@ -2,6 +2,7 @@ package checker import ( "reflect" + "strings" "testing" ) @@ -148,6 +149,14 @@ func TestNumberOfFloat(t *testing.T) { } } +func TestCheckerNamesAreLowerCase(t *testing.T) { + for checker, _ := range makers { + if strings.ToLower(checker) != checker { + t.Fail() + } + } +} + func BenchmarkCheck(b *testing.B) { type Address struct { Street string `checkers:"required"` diff --git a/doc/checkers/ascii.md b/doc/checkers/ascii.md index 8ad0cec..8f7efe9 100644 --- a/doc/checkers/ascii.md +++ b/doc/checkers/ascii.md @@ -1,10 +1,10 @@ # ASCII Checker -The ```ASCII``` checker checks if the given string consists of only ASCII characters. If the string contains non-ASCII characters, the checker will return the ```NOT_ASCII``` result. Here is an example: +The ```ascii``` checker checks if the given string consists of only ASCII characters. If the string contains non-ASCII characters, the checker will return the ```NOT_ASCII``` result. Here is an example: ```golang type User struct { - Username string `checkers:"ASCII"` + Username string `checkers:"ascii"` } user := &User{ @@ -17,7 +17,7 @@ if !valid { } ``` -In your custom checkers, you can call the ```ASCII``` checker function ```IsASCII``` to validate the user input. Here is an example: +In your custom checkers, you can call the ```ascii``` checker function ```IsASCII``` to validate the user input. Here is an example: ```golang result := IsASCII("Checker")