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

Usable error message with value and pattern for RegExp errors #55

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from

Conversation

bieli
Copy link

@bieli bieli commented Mar 23, 2017

It's proposal for usable error messages with RegExp validation rules.

@bieli bieli changed the title Adding error message with pattern for RegExp errors Usable error message with value and pattern for RegExp errors Mar 23, 2017
@jameshartig
Copy link
Collaborator

@bieli looks like you forgot to import errors and fmt.

@@ -210,7 +210,7 @@ func regex(v interface{}, param string) error {
}

if !re.MatchString(s) {
return ErrRegexp
return TextErr{errors.New(fmt.Sprintf("regular expression mismatch - value: '%s', expected pattern: '%s'", s, param))}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use fmt.Errorf instead of error.New(fmt.Sprintf(...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants