class GlobalPhoneValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/global_phone/validator.rb, line 4
def validate_each(record, attribute, value)
  args = [value]
  if (using = options[:using]) && (country_code = record.send(using))
    args << country_code
  end
  unless GlobalPhone.validate(*args)
    record.errors.add attribute, :invalid_phone_number, country_code: country_code
  end
end