Validating phone number with country code for (Twilio)

Greetings, I am trying to build a regex that checks whether or not a phone number is formatted correctly for Twilio.

validates_format_of :phone_number, :with => …
If the format is incorrect, Twilio is unable to send back the api response to the correct conversation record. Does anyone know how to build a regex that follows this format +11235666666?

What is the format? + followed by 11 digits?

2.7.1 :001 > re = /\+\d\d\d\d\d\d\d\d\d\d\d/
2.7.1 :002 > "+11235666666" =~ re
 => 0 
2.7.1 :003 > "11235666666" =~ re
 => nil 
2.7.1 :004 > "11235666" =~ re
 => nil 
2.7.1 :005 > "+11235666" =~ re
 => nil 

If you have other constraints, replace the relevant \d with the required value/range.

Very nice. Thank you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs