Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clarify that underscores are allowed in validation error message #119

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func init() {
// AlphaDash check if provided field contains valid letters, numbers, underscore and dash
AddCustomRule("alpha_dash", func(field string, vlaue string, message string, value interface{}) error {
str := toString(value)
err := fmt.Errorf("The %s may only contain letters, numbers, and dashes", field)
err := fmt.Errorf("The %s may only contain letters, numbers, underscores, and dashes", field)
if message != "" {
err = errors.New(message)
}
Expand All @@ -195,10 +195,10 @@ func init() {
return nil
})

// AlphaDash check if provided field contains valid letters, numbers, underscore and dash
// AlphaSpace check if provided field contains valid letters, numbers, underscores, dashes and space
AddCustomRule("alpha_space", func(field string, vlaue string, message string, value interface{}) error {
str := toString(value)
err := fmt.Errorf("The %s may only contain letters, numbers, dashes, space", field)
err := fmt.Errorf("The %s may only contain letters, numbers, underscores, dashes, and space", field)
if message != "" {
err = errors.New(message)
}
Expand Down