Class: Schemurai::Internal::Evaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/schemurai/evaluator.rb

Instance Method Summary collapse

Constructor Details

#initialize(graph, root, content: false, format: false) ⇒ Evaluator

Returns a new instance of Evaluator.



12
13
14
15
16
17
18
19
# File 'lib/schemurai/evaluator.rb', line 12

def initialize(graph, root, content: false, format: false)
  @validate_content = content
  @validate_format = format
  @graph = graph
  @root = root
  @regexps = nil
  @active = nil
end

Instance Method Details

#valid?(instance) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
34
# File 'lib/schemurai/evaluator.rb', line 27

def valid?(instance)
  @error_callback = nil
  @error_count = 0
  @track_dynamic_scope = @graph.dynamic_scope?
  @instance_path = nil
  @schema_path = nil
  evaluate_valid(@root, instance)
end

#validate(instance) ⇒ Object



21
22
23
24
25
# File 'lib/schemurai/evaluator.rb', line 21

def validate(instance)
  errors = []
  each_error(instance) { |error| errors << error }
  Result.new(errors)
end