Class: PhoneValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- PhoneValidator
- Defined in:
- lib/casey_jones/validation/phone_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 |
# File 'lib/casey_jones/validation/phone_validator.rb', line 2 def validate_each(record,attribute,value) r= value.strip.empty? || value.gsub(/\D/, '').length.in?([9,10]) record.errors[attribute] << ([:message] || "must have 9 or 10 numeric digits") unless r end |