Sha256: e19f7c287ebba0af622bb0931c4c6f437fa6b3d44c270dea8a11d873ee8b2ca0
Contents?: true
Size: 866 Bytes
Versions: 17
Compression:
Stored size: 866 Bytes
Contents
module MCollective module Validator class TypecheckValidator def self.validate(validator, validation_type) raise ValidatorError, "value should be a #{validation_type}" unless check_type(validator, validation_type) end def self.check_type(validator, validation_type) case validation_type when Class validator.is_a?(validation_type) when :integer validator.is_a?(Integer) when :float validator.is_a?(Float) when :number validator.is_a?(Numeric) when :string validator.is_a?(String) when :boolean [TrueClass, FalseClass].include?(validator.class) when :array validator.is_a?(Array) when :hash validator.is_a?(Hash) else false end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems