Class: RussianPhone::FormatValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/russian_phone/format_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/russian_phone/format_validator.rb', line 5

def validate(record)
  options[:fields].each do |field|
    unless record.send(field).phone.blank?
      record.errors[field] << 'Неверный телефонный номер' unless record.send(field).valid? && record.send(field).city_allowed?
    end
  end
end