Class: Chemicalml::Convention::Molecular::Constraints::MoleculeMustHaveId

Inherits:
Constraint::NodeConstraint show all
Defined in:
lib/chemicalml/convention/molecular/constraints/molecule_must_have_id.rb

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/chemicalml/convention/molecular/constraints/molecule_must_have_id.rb', line 8

def check_node(node, path)
  return [] unless node.is_a?(Chemicalml::Cml::Role::Molecule)

  return [] unless node.id.to_s.empty?

  [violation(path: path.empty? ? "molecule" : path.join("/"),
             message: "molecule must have an id attribute")]
end