Module: Tamara::JsonSchemas::Types::Integer

Defined in:
lib/tamara/json_schemas/types/integer.rb

Class Method Summary collapse

Class Method Details

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



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

def self.schema(allows_null: false, min: nil, max: nil, default: nil)
  {
    "$schema": "http://json-schema.org/draft-06/schema",
    type: ["integer", (allows_null ? "null" : nil)].compact,
    minimum: min,
    maximum: max,
    default: default
  }.compact
end