class Apipie::Validator::BooleanValidator
Public Class Methods
build(param_description, argument, options, block)
click to toggle source
# File lib/apipie/validator.rb, line 473 def self.build(param_description, argument, options, block) if argument == :bool || argument == :boolean || boolean_array?(argument) self.new(param_description) end end
Private Class Methods
boolean_array?(argument)
click to toggle source
# File lib/apipie/validator.rb, line 479 def self.boolean_array?(argument) argument.is_a?(Array) && (argument - [true, false]) == [] end
Public Instance Methods
description()
click to toggle source
# File lib/apipie/validator.rb, line 483 def description string = %w(true false 1 0).map { |value| format_description_value(value) }.join(', ') "Must be one of: #{string}." end
expected_type()
click to toggle source
# File lib/apipie/validator.rb, line 492 def expected_type 'boolean' end
ignore_allow_blank?()
click to toggle source
# File lib/apipie/validator.rb, line 488 def ignore_allow_blank? true end
validate(value)
click to toggle source
# File lib/apipie/validator.rb, line 469 def validate(value) %w[true false 1 0].include?(value.to_s) end