Class: MCollective::Validator::TypecheckValidator
- Inherits:
-
Object
- Object
- MCollective::Validator::TypecheckValidator
- Defined in:
- lib/mcollective/validator/typecheck_validator.rb
Class Method Summary collapse
Class Method Details
.check_type(validator, validation_type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mcollective/validator/typecheck_validator.rb', line 8 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 |
.validate(validator, validation_type) ⇒ Object
4 5 6 |
# File 'lib/mcollective/validator/typecheck_validator.rb', line 4 def self.validate(validator, validation_type) raise ValidatorError, "value should be a #{validation_type.to_s}" unless check_type(validator, validation_type) end |