lib/validators/phony_validator.rb in phony_rails-0.7.2 vs lib/validators/phony_validator.rb in phony_rails-0.7.3

- old
+ new

@@ -6,10 +6,12 @@ # Validates a String using Phony.plausible? method. def validate_each(record, attribute, value) return if value.blank? @record = record + + value = PhonyRails.normalize_number value, default_country_code: normalized_country_code if normalized_country_code @record.errors.add(attribute, error_message) if not Phony.plausible?(value, cc: country_number) end private @@ -33,9 +35,13 @@ options[:country_code] || record_country_code end def record_country_code @record.country_code if @record.respond_to?(:country_code) + end + + def normalized_country_code + options[:normalized_country_code] end end module ActiveModel