class Apipie::Validator::TypeValidator
validate arguments type
Public Class Methods
build(param_description, argument, options, block)
click to toggle source
# File lib/apipie/validator.rb, line 91 def self.build(param_description, argument, options, block) if argument.is_a?(Class) && (argument != Hash || block.nil?) self.new(param_description, argument) end end
new(param_description, argument)
click to toggle source
Calls superclass method
Apipie::Validator::BaseValidator.new
# File lib/apipie/validator.rb, line 81 def initialize(param_description, argument) super(param_description) @type = argument end
Public Instance Methods
description()
click to toggle source
# File lib/apipie/validator.rb, line 97 def description "Must be a #{@type}" end
expected_type()
click to toggle source
# File lib/apipie/validator.rb, line 101 def expected_type if @type.ancestors.include? Hash 'hash' elsif @type.ancestors.include? Array 'array' elsif @type.ancestors.include? Numeric 'numeric' else 'string' end end
validate(value)
click to toggle source
# File lib/apipie/validator.rb, line 86 def validate(value) return false if value.nil? value.is_a? @type end