Class: PhoneValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- PhoneValidator
- Defined in:
- lib/validations/phone_validator.rb
Overview
basic phone format validator
Constant Summary collapse
- REGEXP =
/^1\d{10}$/
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 |
# File 'lib/validations/phone_validator.rb', line 4 def validate_each(record, attribute, value) record.errors.add attribute, ([:message] || I18n.t('rails_validation.phone.invalid')) unless value =~ REGEXP end |