Sha256: 04048d9a5b2a0d9edf460c263a25d8a4f3d041e483fd2a71966d983e8193c951

Contents?: true

Size: 422 Bytes

Versions: 2

Compression:

Stored size: 422 Bytes

Contents

# Uses the Phony.plausible method to validate an attribute.
# Usage:
#   validate :phone_number, :phony_number => true
class PhonyNumberValidator < ActiveModel::EachValidator

  # Validates a String using Phony.plausible? method.
  def validate_each(record, attribute, value)
    return if value.blank?
    record.errors[attribute] << (options[:message] || "is an invalid number") if not Phony.plausible?(value)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phony_number-0.0.2 lib/validators/phony_number_validator.rb
phony_number-0.0.1 lib/validators/phony_number_validator.rb