Class: Chemicalml::Convention::Dictionary::Constraints::EntryMustContainDefinition

Inherits:
Constraint::NodeConstraint show all
Defined in:
lib/chemicalml/convention/dictionary/constraints/entry_must_contain_definition.rb

Overview

An <entry> MUST contain a single definition child element. The schema allows it as a string; this constraint enforces presence.

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



12
13
14
15
16
17
# File 'lib/chemicalml/convention/dictionary/constraints/entry_must_contain_definition.rb', line 12

def check_node(node, path)
  return [] unless node.definition.to_s.strip.empty?

  [violation(path: path.join('/'),
             message: "entry #{node.id.inspect} must contain a single definition child")]
end