Sha256: f28561a28d3d9bd04b9354007f914ae52265ba461e6f9b7d89764ca1864999ef

Contents?: true

Size: 391 Bytes

Versions: 7

Compression:

Stored size: 391 Bytes

Contents

# coding: utf-8

module RussianPhone
  class FormatValidator < ActiveModel::Validator
    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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
russian_phone-0.7.0 lib/russian_phone/format_validator.rb
russian_phone-0.6.1 lib/russian_phone/format_validator.rb
russian_phone-0.6.0 lib/russian_phone/format_validator.rb
russian_phone-0.5.3 lib/russian_phone/format_validator.rb
russian_phone-0.5.2 lib/russian_phone/format_validator.rb
russian_phone-0.5.1 lib/russian_phone/format_validator.rb
russian_phone-0.5.0 lib/russian_phone/format_validator.rb