ValidatePhone validates the phone number.
(phone string)
| 147 | |
| 148 | // ValidatePhone validates the phone number. |
| 149 | func ValidatePhone(phone string) error { |
| 150 | phoneNumber, err := phonenumbers.Parse(phone, "") |
| 151 | if err != nil { |
| 152 | return err |
| 153 | } |
| 154 | if !phonenumbers.IsValidNumber(phoneNumber) { |
| 155 | return errors.New("invalid phone number") |
| 156 | } |
| 157 | return nil |
| 158 | } |
| 159 | |
| 160 | // emailRegex is based on the WHATWG HTML spec for valid email addresses. |
| 161 | // https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address |
no outgoing calls