class EffectiveTelValidator

An ActiveRecord validator for any phone field that you would use with effective_tel

validates :phone, effective_tel: true

Constants

PATTERN

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/validators/effective_tel_validator.rb, line 8
def validate_each(record, attribute, value)
  if value.present?
    record.errors.add(attribute, 'is invalid') unless PATTERN =~ value
  end
end