Project

General

Profile

Download (1.11 KB) Statistics
| Branch: | Tag: | Revision:

foreman-docker / app / models / exposed_port.rb @ 26c5ba32

1
class ExposedPort < Parameter
2
  attr_accessible :priority
3
  # The Parameter class from which ExposedPort class inherits,validates for the
4
  # presence of an  associated domain, operating system, host or host group. We
5
  # will have to reset those validations for the  ExposedPort class as  they do
6
  # not make any sense for the context in which this class is being used here.
7
  ExposedPort.reset_callbacks(:validate)
8

    
9
  belongs_to :container, :foreign_key => :reference_id, :inverse_of => :exposed_ports
10
  audited :except => [:priority], :associated_with => :container, :allow_mass_assignment => true
11
  validates :name,  :uniqueness => { :scope => :reference_id }
12
  validates :name,  :numericality => { :only_integer => true,
13
                                       :greater_than => 0,
14
                                       :less_than_or_equal_to => 655_35,
15
                                       :message => "%{value} is not a valid port number" }
16

    
17
  validates :value, :presence => true,
18
                    :inclusion => { :in => %w(tcp udp),
19
                                    :message => "%{value} is not a valid protocol" }
20
end