Class: Apipie::Validator::BooleanValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #error, find, inherited, #initialize, #inspect, #inspected_fields, #merge_with, #param_name, #params_ordered, #to_json, #to_s, #valid?
Class Method Details
.build(param_description, argument, options, block) ⇒ Object
459
460
461
462
463
|
# File 'lib/apipie/validator.rb', line 459
def self.build(param_description, argument, options, block)
if argument == :bool || argument == :boolean
self.new(param_description)
end
end
|
Instance Method Details
#description ⇒ Object
469
470
471
472
|
# File 'lib/apipie/validator.rb', line 469
def description
string = %w(true false 1 0).map { |value| "<code>#{value}</code>" }.join(', ')
"Must be one of: #{string}"
end
|
#expected_type ⇒ Object
465
466
467
|
# File 'lib/apipie/validator.rb', line 465
def expected_type
'boolean'
end
|
#validate(value) ⇒ Object
455
456
457
|
# File 'lib/apipie/validator.rb', line 455
def validate(value)
%w[true false 1 0].include?(value.to_s)
end
|