Skip to content

Commit

Permalink
Fix bug which considered '#' and '*' as invalid
Browse files Browse the repository at this point in the history
input for gather
  • Loading branch information
jtwatson committed Apr 11, 2020
1 parent ca64eb3 commit f06f9c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
// RequestValues hold form values from a validated Request
type RequestValues map[string]string

// CallDuration Parses the duration rom the string value
// CallDuration Parses the duration from the string value
func (r RequestValues) CallDuration() (int, error) {
var duration int
if r["CallDuration"] != "" {
Expand Down Expand Up @@ -156,5 +156,5 @@ var fieldValidators = map[string]valCfg{
// "SipUsername": "SipUsername",
// "SipCallId": "SipCallId",
// "SipSourceIp": "SipSourceIp",
"Digits": valCfg{valFunc: validNumeric},
"Digits": valCfg{valFunc: validateKeyPadEntry},
}
10 changes: 5 additions & 5 deletions validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func validatePhoneNumber(num string) error {
return nil
}

func validNumeric(v interface{}, param string) error {
func validateKeyPadEntry(v interface{}, param string) error {
switch num := v.(type) {
case string:
if num == "" {
Expand All @@ -53,22 +53,22 @@ func validNumeric(v interface{}, param string) error {
}
return errors.New("Required")
}
return validateNumeric(num)
return validateNumericPoundStar(num)
case *string:
if num == nil {
if param == "allowempty" {
return nil
}
return errors.New("Required")
}
return validateNumeric(*num)
return validateNumericPoundStar(*num)
default:
return fmt.Errorf("validDatastoreKey: Unexpected type %T", num)
}
}

func validateNumeric(v string) error {
return characterList(v, "0123456789")
func validateNumericPoundStar(v string) error {
return characterList(v, "0123456789#*")
}

// characterList checks a string against a list of acceptable characters.
Expand Down

0 comments on commit f06f9c7

Please sign in to comment.