Class: Chemicalml::Convention::Compchem::Constraints::FinalizationMustHaveContent

Inherits:
Chemicalml::Convention::Constraint::NodeConstraint show all
Defined in:
lib/chemicalml/convention/compchem/constraints/finalization_must_have_content.rb

Overview

A finalization module MUST contain at least one of: molecule, propertyList, or a user-defined module child. Per the compchem convention spec.

Instance Method Summary collapse

Methods inherited from Chemicalml::Convention::Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/chemicalml/convention/compchem/constraints/finalization_must_have_content.rb', line 14

def check_node(node, path)
  return [] unless node.dict_ref == 'compchem:finalization'

  has_molecule = (node.molecules || []).any?
  has_prop_list = (node.property_lists || []).any?
  has_user_module = user_module_count(node).positive?
  return [] if has_molecule || has_prop_list || has_user_module

  [violation(path: path.join('/'),
             message: 'finalization module must contain at least one of: ' \
                      'molecule, propertyList, or user-defined module')]
end