class PhoneValidator

Basic check for a telephone number; this should work with most, of not all, writing conventions.

Constants

REGEXP

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/validators/phone_validator.rb, line 11
def validate_each record, attribute, value
  record.errors.add attribute, (options[:message] || I18n.t('rails_validations.phone.invalid')) unless value =~ REGEXP
end