Updated mcollective.init according to OSCI-658
[packages/precise/mcollective.git] / plugins / mcollective / validator / ipv6address_validator.rb
diff --git a/plugins/mcollective/validator/ipv6address_validator.rb b/plugins/mcollective/validator/ipv6address_validator.rb
new file mode 100644 (file)
index 0000000..661e8c9
--- /dev/null
@@ -0,0 +1,16 @@
+module MCollective
+  module Validator
+    class Ipv6addressValidator
+      require 'ipaddr'
+
+      def self.validate(validator)
+        begin
+          ip = IPAddr.new(validator)
+          raise ValidatorError, "value should be an ipv6 adddress" unless ip.ipv6?
+        rescue
+          raise ValidatorError, "value should be an ipv6 address"
+        end
+      end
+    end
+  end
+end