Class: ApipieDSL::Validator::BooleanValidator
Instance Attribute Summary
#param_description
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #docs, find, inherited, #initialize, #inspect, #inspected_fields, #merge_with, #sub_params, #to_s, #valid?
Class Method Details
.build(param_description, argument, _options, _block) ⇒ Object
402
403
404
405
406
|
# File 'lib/apipie_dsl/validator.rb', line 402
def self.build(param_description, argument, _options, _block)
return unless %i[bool boolean].include?(argument)
new(param_description)
end
|
Instance Method Details
#description ⇒ Object
412
413
414
415
|
# File 'lib/apipie_dsl/validator.rb', line 412
def description
string = %w[true false 1 0].map { |value| "<code>#{value}</code>" }.join(', ')
"Must be one of: #{string}"
end
|
#expected_type ⇒ Object
417
418
419
|
# File 'lib/apipie_dsl/validator.rb', line 417
def expected_type
'boolean'
end
|
#validate(value) ⇒ Object
408
409
410
|
# File 'lib/apipie_dsl/validator.rb', line 408
def validate(value)
%w[true false 1 0].include?(value.to_s)
end
|