Sha256: 8a84ecd250aece7c1d8fa3fe0c26402e031280cb4451edec91579fcd67c107d5

Contents?: true

Size: 409 Bytes

Versions: 1

Compression:

Stored size: 409 Bytes

Contents

# Uses the Phony.plausible method to validate an attribute.
# Usage:
#   validate :phone_number, :phony => true
class PhonyValidator < 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

1 entries across 1 versions & 1 rubygems

Version Path
phony_rails-0.0.4 lib/validators/phony_validator.rb