b85a2071c9cc034e2d427982f3c1f2f630916550
[packages/precise/mcollective.git] / plugins / mcollective / validator / ipv4address_validator.rb
1 module MCollective
2   module Validator
3     class Ipv4addressValidator
4       require 'ipaddr'
5
6       def self.validate(validator)
7         begin
8           ip = IPAddr.new(validator)
9           raise ValidatorError, "value should be an ipv4 adddress" unless ip.ipv4?
10         rescue
11           raise ValidatorError, "value should be an ipv4 address"
12         end
13       end
14     end
15   end
16 end