Class: ApipieDSL::Validator::BooleanValidator

Inherits:
BaseValidator show all
Defined in:
lib/apipie_dsl/validator.rb

Instance Attribute Summary

Attributes inherited from BaseValidator

#param_description

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseValidator

#==, #docs, find, inherited, #initialize, #inspect, #inspected_fields, #merge_with, #sub_params, #to_s, #valid?

Constructor Details

This class inherits a constructor from ApipieDSL::Validator::BaseValidator

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

#descriptionObject



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_typeObject



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