Class: ActiveModel::Validations::PhoneValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::PhoneValidator
- Defined in:
- lib/active_model/validations/phone_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 |
# File 'lib/active_model/validations/phone_validator.rb', line 4 def validate_each(record, attribute, value) country_code = Country.new([:country].to_s.upcase).country_code unless [:country].blank? record.errors.add(attribute, [:message]) if value.blank? || ! ([:country].blank? ? Phony.plausible?(value) : Phony.plausible?(value, :cc => country_code) ) end |