class PhoneValidator
PhoneValidator
makes phone validation natural for ActiveModel object. Validation using global_phone.
Public Class Methods
default_options()
click to toggle source
# File lib/phone_validator.rb, line 5 def self.default_options @@default_options end
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/phone_validator.rb, line 9 def validate_each(record, attribute, value) options = @@default_options.merge(self.options) unless GlobalPhone.validate(value) record.errors.add(attribute, options[:message] || :invalid) end end