Sha256: 0edf5d1fb3f1ac3007e4e550f79443b0f7d6515b9a242af76890917dcdbc071c
Contents?: true
Size: 794 Bytes
Versions: 28
Compression:
Stored size: 794 Bytes
Contents
module MCollective module Validator class TypecheckValidator def self.validate(validator, validation_type) raise ValidatorError, "value should be a #{validation_type.to_s}" 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?(Fixnum) 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) else false end end end end end
Version data entries
28 entries across 28 versions & 2 rubygems