Class: MCollective::Validator::Ipv4addressValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/mcollective/validator/ipv4address_validator.rb

Class Method Summary collapse

Class Method Details

.validate(validator) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/mcollective/validator/ipv4address_validator.rb', line 6

def self.validate(validator)
  begin
    ip = IPAddr.new(validator)
    raise ValidatorError, "value should be an ipv4 adddress" unless ip.ipv4?
  rescue
    raise ValidatorError, "value should be an ipv4 address"
  end
end