module StrongJSON::Types

Public Instance Methods

any() click to toggle source
# File lib/strong_json/types.rb, line 39
def any
  StrongJSON::Type::Base.new(:any)
end
any?() click to toggle source
# File lib/strong_json/types.rb, line 43
def any?
  optional(any)
end
array(type = any) click to toggle source
# File lib/strong_json/types.rb, line 11
def array(type = any)
  Type::Array.new(type)
end
array?(ty) click to toggle source
# File lib/strong_json/types.rb, line 83
def array?(ty)
  optional(array(ty))
end
boolean() click to toggle source
# File lib/strong_json/types.rb, line 35
def boolean
  StrongJSON::Type::Base.new(:boolean)
end
boolean?() click to toggle source
# File lib/strong_json/types.rb, line 75
def boolean?
  optional(boolean)
end
enum(*types, detector: nil) click to toggle source
# File lib/strong_json/types.rb, line 55
def enum(*types, detector: nil)
  StrongJSON::Type::Enum.new(types, detector)
end
enum?(*types, detector: nil) click to toggle source
# File lib/strong_json/types.rb, line 95
def enum?(*types, detector: nil)
  optional(enum(*types, detector: detector))
end
hash(type) click to toggle source
# File lib/strong_json/types.rb, line 99
def hash(type)
  StrongJSON::Type::Hash.new(type)
end
hash?(type) click to toggle source
# File lib/strong_json/types.rb, line 103
def hash?(type)
  optional(hash(type))
end
integer() click to toggle source
# File lib/strong_json/types.rb, line 31
def integer
  StrongJSON::Type::Base.new(:integer)
end
integer?() click to toggle source
# File lib/strong_json/types.rb, line 67
def integer?
  optional(integer)
end
literal(value) click to toggle source
# File lib/strong_json/types.rb, line 51
def literal(value)
  StrongJSON::Type::Literal.new(value)
end
literal?(value) click to toggle source
# File lib/strong_json/types.rb, line 91
def literal?(value)
  optional(literal(value))
end
number() click to toggle source
# File lib/strong_json/types.rb, line 27
def number
  StrongJSON::Type::Base.new(:number)
end
number?() click to toggle source
# File lib/strong_json/types.rb, line 71
def number?
  optional(number)
end
numeric() click to toggle source
# File lib/strong_json/types.rb, line 23
def numeric
  StrongJSON::Type::Base.new(:numeric)
end
numeric?() click to toggle source
# File lib/strong_json/types.rb, line 63
def numeric?
  optional(numeric)
end
object(fields = {}) click to toggle source
# File lib/strong_json/types.rb, line 3
def object(fields = {})
  if fields.empty?
    Type::Object.new(fields, on_unknown: :ignore, exceptions: Set.new)
  else
    Type::Object.new(fields, on_unknown: :reject, exceptions: Set.new)
  end
end
object?(fields={}) click to toggle source
# File lib/strong_json/types.rb, line 87
def object?(fields={})
  optional(object(fields))
end
optional(type = any) click to toggle source
# File lib/strong_json/types.rb, line 15
def optional(type = any)
  Type::Optional.new(type)
end
string() click to toggle source
# File lib/strong_json/types.rb, line 19
def string
  StrongJSON::Type::Base.new(:string)
end
string?() click to toggle source
# File lib/strong_json/types.rb, line 59
def string?
  optional(string)
end
symbol() click to toggle source
# File lib/strong_json/types.rb, line 47
def symbol
  StrongJSON::Type::Base.new(:symbol)
end
symbol?() click to toggle source
# File lib/strong_json/types.rb, line 79
def symbol?
  optional(symbol)
end