Class: PhonyPlausibleValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- PhonyPlausibleValidator
- Defined in:
- lib/validators/phony_validator.rb
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ Object
Validates a String using Phony.plausible? method.
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
Validates a String using Phony.plausible? method.
9 10 11 12 13 14 15 16 |
# File 'lib/validators/phony_validator.rb', line 9 def validate_each(record, attribute, value) return if value.blank? @record = record value = PhonyRails.normalize_number(value.dup, default_country_code: normalized_country_code) if normalized_country_code value = PhonyRails.extract_extension(value).first @record.errors.add(attribute, ) unless Phony.plausible?(value, cc: country_number) end |