Class: Journeybook::Ai::TemplateValidator

Inherits:
Object
  • Object
show all
Defined in:
app/services/journeybook/ai/template_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser: ComponentParser.new) ⇒ TemplateValidator

Returns a new instance of TemplateValidator.



4
5
6
# File 'app/services/journeybook/ai/template_validator.rb', line 4

def initialize(parser: ComponentParser.new)
  @parser = parser
end

Instance Method Details

#errors_for(markdown, template) ⇒ Object



8
9
10
11
12
13
14
# File 'app/services/journeybook/ai/template_validator.rb', line 8

def errors_for(markdown, template)
  expected = @parser.parse(template.markdown).map(&:name)
  actual = @parser.parse(markdown).map(&:name)
  return [] if actual == expected

  [ "AI draft must use the #{template.name} template components in the approved order." ]
end