Class: Spree::Addresses::PhoneValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Spree::Addresses::PhoneValidator
- Defined in:
- app/validators/spree/addresses/phone_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate(address) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/validators/spree/addresses/phone_validator.rb', line 10 def validate(address) return if !address.require_phone? || address.phone.blank? || address.country.blank? || address.country_iso.blank? phone = Phonelib.parse(address.phone) unless phone.valid_for_country?(address.country_iso) address.errors.add(:phone, :invalid) end end |