Class: Apipie::Validator::BooleanValidator

Inherits:
BaseValidator show all
Defined in:
lib/apipie/validator.rb

Instance Attribute Summary

Attributes inherited from BaseValidator

#param_description

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseValidator

#error, find, inherited, #initialize, #merge_with, #param_name, #params_ordered, #to_json, #to_s, #valid?

Constructor Details

This class inherits a constructor from Apipie::Validator::BaseValidator

Class Method Details

.build(param_description, argument, options, block) ⇒ Object



404
405
406
407
408
# File 'lib/apipie/validator.rb', line 404

def self.build(param_description, argument, options, block)
  if argument == :bool
    self.new(param_description)
  end
end

Instance Method Details

#descriptionObject



414
415
416
# File 'lib/apipie/validator.rb', line 414

def description
  "Must be 'true' or 'false'"
end

#expected_typeObject



410
411
412
# File 'lib/apipie/validator.rb', line 410

def expected_type
  'boolean'
end

#validate(value) ⇒ Object



400
401
402
# File 'lib/apipie/validator.rb', line 400

def validate(value)
  %w[true false].include?(value.to_s)
end