Module: Tamara::JsonSchemas::Types::String

Included in:
Orders::Details::MerchantOrder
Defined in:
lib/tamara/json_schemas/types/string.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.schema(allows_null: false, max_length: nil, default: nil) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/tamara/json_schemas/types/string.rb', line 5

def self.schema(allows_null: false, max_length: nil, default: nil)
  {
    "$schema": "http://json-schema.org/draft-06/schema",
    type: ["string", (allows_null ? "null" : nil)].compact,
    minLength: allows_null ? 0 : 1,
    maxLength: max_length,
    default: default
  }.compact
end

Instance Method Details

#schemaObject



15
16
17
# File 'lib/tamara/json_schemas/types/string.rb', line 15

def schema
  Tamara::JsonSchemas::Types::String.schema
end