aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/concerns/network_restrictions.rb
blob: 9c5d159b6e56f362e5d4c5c47d0f6b0021a821ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module NetworkRestrictions
  extend ActiveSupport::Concern

  included do
    include ObjectidRestrictions

    with_options if: :hub_restricted? do |n|
      # HUB-3
      n.validate :specific_objectid
      # HUB-4
      #n.validates_length_of :name, :minimum => 1, :maximum => 75
      n.validates :name, length: { in: 1..75 }
      # HUB-5
      #n.validates_format_of :registration_number, :with => %r{\A[\d]{1,8}\z}
      #n.validates_uniqueness_of :registration_number
      n.validates :registration_number,
                  uniqueness: true,
                  numericality: { only_integer: true },
                  length: { in: 1..8 }
    end
  end
  def specific_objectid
    validate_specific_objectid( 3)
  end
end