Class: Apipie::Validator::BooleanValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #error, find, #format_description_value, inherited, #initialize, #inspect, #inspected_fields, #merge_with, #param_name, #params_ordered, raise_if_missing_params, #to_json, #to_s, #valid?
Class Method Details
.build(param_description, argument, options, block) ⇒ Object
484
485
486
487
488
|
# File 'lib/apipie/validator.rb', line 484
def self.build(param_description, argument, options, block)
if argument == :bool || argument == :boolean || boolean_array?(argument)
self.new(param_description)
end
end
|
Instance Method Details
#description ⇒ Object
494
495
496
497
|
# File 'lib/apipie/validator.rb', line 494
def description
string = %w(true false 1 0).map { |value| format_description_value(value) }.join(', ')
"Must be one of: #{string}."
end
|
#expected_type ⇒ Object
503
504
505
|
# File 'lib/apipie/validator.rb', line 503
def expected_type
'boolean'
end
|
#ignore_allow_blank? ⇒ Boolean
499
500
501
|
# File 'lib/apipie/validator.rb', line 499
def ignore_allow_blank?
true
end
|
#validate(value) ⇒ Object
480
481
482
|
# File 'lib/apipie/validator.rb', line 480
def validate(value)
%w[true false 1 0].include?(value.to_s)
end
|