Class: Chemicalml::Convention::Molecular::Constraints::MoleculeBondArrayMutuallyExclusiveWithChildren

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

Overview

Molecular convention: a <molecule> MAY hold a bondArray OR child <molecule> elements, but not both.

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/chemicalml/convention/molecular/constraints/molecule_bond_array_mutually_exclusive_with_children.rb', line 11

def check_node(node, path)
  return [] if node.bond_array.nil?
  return [] if (node.molecules || []).empty?

  [violation(
    path: (path + [describe(node)]).join('/'),
    message: "molecule #{node.id.inspect} has both a bondArray " \
             'and child molecule elements — these are mutually exclusive'
  )]
end