How to Validate an E.164 Phone Number in Go

1 · Twilio · Sept. 11, 2023, 10:39 a.m.
Summary
If you're sending SMS, MMS — or performing any other form of communication using Twilio's Programmable Messaging API — you'll know that phone numbers must be in E.164 format. The question is, how can you validate them in Go? Well, in this short tutorial, you're going to learn how, using Twilio's E.164 regular expression (tl;dr, it's ^\+[1-9]\d{1,14}$). Actually, you're going to learn a bit more than that. Just showing the core code to validate a phone number would only take about 30 seconds. So...