From f06f9c72e32bd964d0e14f5cba0b54937e6e1b17 Mon Sep 17 00:00:00 2001 From: Joseph Watson Date: Sat, 11 Apr 2020 09:54:26 -0400 Subject: [PATCH] Fix bug which considered '#' and '*' as invalid input for gather --- request.go | 4 ++-- validators.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/request.go b/request.go index ca52cb4..7ca735d 100644 --- a/request.go +++ b/request.go @@ -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"] != "" { @@ -156,5 +156,5 @@ var fieldValidators = map[string]valCfg{ // "SipUsername": "SipUsername", // "SipCallId": "SipCallId", // "SipSourceIp": "SipSourceIp", - "Digits": valCfg{valFunc: validNumeric}, + "Digits": valCfg{valFunc: validateKeyPadEntry}, } diff --git a/validators.go b/validators.go index ddd2932..b675d31 100644 --- a/validators.go +++ b/validators.go @@ -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 == "" { @@ -53,7 +53,7 @@ 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" { @@ -61,14 +61,14 @@ func validNumeric(v interface{}, param string) error { } 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.