Class: Marko::Validators::LostParent

Inherits:
Object
  • Object
show all
Defined in:
lib/marko/validators/lost_parent.rb

Overview

Lost parent validator

Instance Method Summary collapse

Instance Method Details

#call(tree) ⇒ Object

Parameters:

  • tree (Enumerable)


9
10
11
12
13
14
15
16
17
# File 'lib/marko/validators/lost_parent.rb', line 9

def call(tree)
  faulty = tree
    .select{ it[:parent] && it&.parent&.id != it[:parent] }
  
  faulty.map do
    message = "lost parent [#{it[:parent]}] in #{it.markup}"
    Marko::ValidatorError.new(message)
  end
end