class Apipie::Validator::BooleanValidator
Public Class Methods
build(param_description, argument, options, block)
click to toggle source
# File lib/apipie/validator.rb, line 487 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 493 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 497 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 506 def expected_type 'boolean' end
ignore_allow_blank?()
click to toggle source
# File lib/apipie/validator.rb, line 502 def ignore_allow_blank? true end
validate(value)
click to toggle source
# File lib/apipie/validator.rb, line 483 def validate(value) %w[true false 1 0].include?(value.to_s) end