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, #expected_type, find, inherited, #initialize, #merge_with, #param_name, #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



297
298
299
300
301
# File 'lib/apipie/validator.rb', line 297

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

Instance Method Details

#descriptionObject



303
304
305
# File 'lib/apipie/validator.rb', line 303

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

#validate(value) ⇒ Object



293
294
295
# File 'lib/apipie/validator.rb', line 293

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