Skip to content

Commit

Permalink
ASCII checker name fixed. (#74)
Browse files Browse the repository at this point in the history
# Describe Request

Fixes ASCII checker name.

# Change Type

Fix issue.
  • Loading branch information
cinar committed Jun 20, 2023
1 parent 0cb565f commit 3dd1c61
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ascii.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions ascii_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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{
Expand All @@ -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{
Expand Down
9 changes: 9 additions & 0 deletions checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package checker

import (
"reflect"
"strings"
"testing"
)

Expand Down Expand Up @@ -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"`
Expand Down
6 changes: 3 additions & 3 deletions doc/checkers/ascii.md
Original file line number Diff line number Diff line change
@@ -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{
Expand All @@ -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")
Expand Down

0 comments on commit 3dd1c61

Please sign in to comment.