Class: Marko::Tasks::Validate

Inherits:
Object
  • Object
show all
Defined in:
lib/marko/tasks/validate.rb

Overview

Validate tree

Instance Method Summary collapse

Instance Method Details

#call(topic) ⇒ Object

Parameters:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/marko/tasks/validate.rb', line 12

def call(topic)
  validators = 
    [ Validators::NonUniqueId,
      Validators::LostParent,
      Validators::LostIndex,
      Validators::LostLinks          
    ].map(&:new)

  errors = validators
    .inject([]){|errors, validator| errors << validator.call(topic) }
    .flatten
  
  fail Marko::StageError.new('Check stage failed', errors) \
    if errors.any?  
  
  topic
end