Sha256: 70556e26fafa1713898cbd4c571bc95526ac98200cfed020f773506c08137951
Contents?: true
Size: 730 Bytes
Versions: 16
Compression:
Stored size: 730 Bytes
Contents
class PhoneNumberValidator::Validator PHONE_NUMBER_REGEX = /^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i def initialize(phone_number = '+1 (949) 355-6244 ext. 198842') @phone_number = phone_number end def validate_phone_number if (@phone_number.match(PHONE_NUMBER_REGEX)) puts "'%s' is a valid phone number." % @phone_number return true else puts "'%s' is not a valid phone number." % @phone_number return false end end end
Version data entries
16 entries across 16 versions & 1 rubygems