Class: PhonyPlausibleValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
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

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object

Validates a String using Phony.plausible? method.



7
8
9
10
11
12
# File 'lib/validators/phony_validator.rb', line 7

def validate_each(record, attribute, value)
  return if value.blank?

  @record = record
  @record.errors.add(attribute, error_message) if not Phony.plausible?(value, cc: country_number)
end