Top Level Namespace

Defined Under Namespace

Modules: DeepEquality, HashInitialized, Inspectable Classes: AnythingPattern, AnythingValidation, Boolean, CyclicObjectMembersValidation, CyclicPattern, CyclicValueValidation, DisjunctionKey, DisjunctionPattern, DisjunctionValidation, Email, EmailValidation, EmptyObjectMembersValidation, JsonType, ManyKey, ManyObjectMembersValidation, MembersKey, ObjectMembersDisjunctionValidation, ObjectMembersFromObjectValidation, ObjectMembersValidation, ObjectMembersValidationResult, ObjectValidation, OptionalKey, OptionalObjectMembersValidation, PrimitiveTypeValidation, PrimitiveValueValidation, RegexpValidation, SequencedObjectMembersValidation, SingleObjectMemberValidation, URL, URLValidation, UniformArrayPattern, UniformArrayValidation, Validation, ValidationAmbiguity, ValidationFailure, ValidationUnexpected, ValueDisjunctionValidation

Instance Method Summary collapse

Instance Method Details

#__Object



104
105
106
# File 'lib/json_patterns.rb', line 104

def __
  AnythingPattern.new
end

#array_of(value) ⇒ Object



92
93
94
# File 'lib/json_patterns.rb', line 92

def array_of(value)
  UniformArrayPattern.new(value: value)
end

#cyclic(&proc) ⇒ Object



116
117
118
119
120
# File 'lib/json_patterns.rb', line 116

def cyclic(&proc)
  p = CyclicPattern.new
  p.interior = proc.call(p)
  return p
end

#json_type_name(value) ⇒ Object



187
188
189
# File 'lib/json_patterns.rb', line 187

def json_type_name(value)
  JsonType.new_from_value(value).type.to_s
end

#manyObject



881
882
883
# File 'lib/json_patterns.rb', line 881

def many
  ManyKey.new
end

#membersObject



918
919
920
# File 'lib/json_patterns.rb', line 918

def members
  MembersKey.new
end

#one_of(*patterns) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/json_patterns.rb', line 73

def one_of(*patterns)
  case patterns
  when []
    DisjunctionKey.new
  else
    DisjunctionPattern.new(alternatives: patterns)
  end
end

#optionalObject



837
838
839
# File 'lib/json_patterns.rb', line 837

def optional
  OptionalKey.new
end

#set_union(sets) ⇒ Object



3
4
5
# File 'lib/json_patterns.rb', line 3

def set_union(sets)
  sets.reduce { |u, s| u + s }
end

#shallow_value(value) ⇒ Object



191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/json_patterns.rb', line 191

def shallow_value(value)
  case value
  when Hash
    'object'
  when Array
    'array'
  when NilClass
    'null'
  else
    value.inspect
  end
end