Sha256: e6404fee50712a0a91b97172bd083973441b3e26442934100f6abdb15707d03c
Contents?: true
Size: 762 Bytes
Versions: 2
Compression:
Stored size: 762 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) else false end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
choria-mcorpc-support-2.20.8 | lib/mcollective/validator/typecheck_validator.rb |
choria-mcorpc-support-2.20.7 | lib/mcollective/validator/typecheck_validator.rb |