Class: PhonyPlausibleValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- PhonyPlausibleValidator
- Defined in:
- lib/validators/phony_validator.rb
Overview
Uses the Phony.plausible method to validate an attribute. Usage:
validate :phone_number, :phony_plausible => true
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.
7 8 9 10 |
# File 'lib/validators/phony_validator.rb', line 7 def validate_each(record, attribute, value) return if value.blank? record.errors.add(attribute, [:message] || :improbable_phone) if not Phony.plausible?(value, cc: [:country_code]) end |