Class: PhoneValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- PhoneValidator
- Defined in:
- lib/phone_validator.rb
Overview
PhoneValidator makes phone validation natural for ActiveModel object. Validation using global_phone.
Constant Summary collapse
- @@default_options =
{}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.default_options ⇒ Object
5 6 7 |
# File 'lib/phone_validator.rb', line 5 def self. end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/phone_validator.rb', line 9 def validate_each(record, attribute, value) = .merge(self.) unless GlobalPhone.validate(value) record.errors.add(attribute, [:message] || :invalid) end end |