Class: Explicit::Type::Boolean

Inherits:
Explicit::Type show all
Defined in:
lib/explicit/type/boolean.rb

Constant Summary collapse

VALUES =
{
  true => true,
  "true" => true,
  "on" => true,
  "1" => true,
  1 => true,
  false => false,
  "false" => false,
  "off" => false,
  "0" => false,
  0 => false
}.freeze

Instance Attribute Summary

Attributes inherited from Explicit::Type

#auth_type, #default, #description, #nilable, #param_location

Instance Method Summary collapse

Methods inherited from Explicit::Type

#auth_basic?, #auth_bearer?, build, #error_i18n, #mcp_schema, #merge_base_json_schema, #param_location_body?, #param_location_path?, #param_location_query?, #required?, #swagger_i18n, #swagger_schema

Instance Method Details

#json_schema(flavour) ⇒ Object



39
40
41
42
43
# File 'lib/explicit/type/boolean.rb', line 39

def json_schema(flavour)
  {
    type: "boolean"
  }
end

#validate(value) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/explicit/type/boolean.rb', line 17

def validate(value)
  value = VALUES[value]

  return error_i18n("boolean") if value.nil?

  [:ok, value]
end