class MCollective::Validator::TypecheckValidator - mcollective version 2.12.5

# class MCollective::Validator::TypecheckValidator

### Public Class Methods

check_type(validator, validation_type) click to toggle source

       # File lib/mcollective/validator/typecheck_validator.rb
     8 def self.check_type(validator, validation_type)
     9   case validation_type
    10     when Class
    11       validator.is_a?(validation_type)
    12     when :integer
    13       validator.is_a?(Integer)
    14     when :float
    15       validator.is_a?(Float)
    16     when :number
    17       validator.is_a?(Numeric)
    18     when :string
    19       validator.is_a?(String)
    20     when :boolean
    21       [TrueClass, FalseClass].include?(validator.class)
    22     else
    23       false
    24   end
    25 end

validate(validator, validation_type) click to toggle source

      # File lib/mcollective/validator/typecheck_validator.rb
    4 def self.validate(validator, validation_type)
    5   raise ValidatorError, "value should be a #{validation_type.to_s}" unless check_type(validator, validation_type)
    6 end