Project

General

Profile

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

foreman-docker / app / models / exposed_port.rb @ cc6d0d73

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

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

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