aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/concerns/company_restrictions.rb
blob: 3a5f17da860184bbc3211d5f96dc2124c8d8af96 (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 CompanyRestrictions
  extend ActiveSupport::Concern

  included do
    include ObjectidRestrictions

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