Class: TextBelt::PhoneValidator
- Inherits:
-
Object
- Object
- TextBelt::PhoneValidator
- Defined in:
- lib/textbelt/validators/phone_validator.rb
Overview
Validator for outgoing phone numbers
Class Method Summary collapse
-
.validate(phone_number, country) ⇒ Boolean
Get a list of categories from the service.
Class Method Details
.validate(phone_number, country) ⇒ Boolean
Get a list of categories from the service
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/textbelt/validators/phone_validator.rb', line 20 def validate(phone_number, country) unless is_a_string?(phone_number) raise TextBelt::Errors::IntegerPhoneError, "Please ensure to pass phone numbers as strings." end phone = Phonelib.parse phone_number if phone.impossible? raise TextBelt::Errors::InvalidPhoneNumberError, "#{phone_number} is not valid in destination country #{country}" end end |