Module: RustyJSONSchema

Defined in:
lib/rusty_json_schema.rb,
lib/rusty_json_schema/binding.rb,
lib/rusty_json_schema/version.rb,
lib/rusty_json_schema/validator.rb,
lib/rusty_json_schema/nodes_array.rb

Overview

JSON Schema validation

## Example

validator = RustyJSONSchema.build(schema)

validator.valid?(event)
# => true/false

validator.validate(event)
# => [] / ["...error messages", ...]

Defined Under Namespace

Modules: Binding Classes: Error, NodesArray, Validator

Constant Summary collapse

VERSION =
"0.15.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.processorObject



31
32
33
# File 'lib/rusty_json_schema.rb', line 31

def processor
  @processor ||= JSON
end

Class Method Details

.build(schema) ⇒ Object

Helper method that returns new instance of pointer to Validator struct.



45
46
47
# File 'lib/rusty_json_schema.rb', line 45

def build(schema)
  RustyJSONSchema::Binding.new(dump(schema))
end

.dump(data) ⇒ Object



35
36
37
38
39
40
# File 'lib/rusty_json_schema.rb', line 35

def dump(data)
  case data
  when String then data
  else processor.dump(data)
  end
end