| 35 | } |
| 36 | |
| 37 | func (input *request) sanitizeContact(owner string, contact string) string { |
| 38 | contact = strings.TrimSpace(contact) |
| 39 | |
| 40 | if len(contact) < 8 || !input.isDigits(contact) { |
| 41 | return contact |
| 42 | } |
| 43 | |
| 44 | regionPhoneNumber, err := phonenumbers.Parse(owner, phonenumbers.UNKNOWN_REGION) |
| 45 | if err != nil { |
| 46 | return contact |
| 47 | } |
| 48 | |
| 49 | if number, err := phonenumbers.Parse(contact, phonenumbers.GetRegionCodeForNumber(regionPhoneNumber)); err == nil { |
| 50 | contact = phonenumbers.Format(number, phonenumbers.E164) |
| 51 | } |
| 52 | |
| 53 | return contact |
| 54 | } |
| 55 | |
| 56 | // sanitizeBool sanitizes a boolean string |
| 57 | func (input *request) sanitizeBool(value string) string { |