Class: Chemicalml::Convention::UnitDictionary::Constraints::UnitMustHaveParentSi

Inherits:
Constraint::NodeConstraint show all
Defined in:
lib/chemicalml/convention/unit_dictionary/constraints/unit_must_have_parent_si.rb

Overview

A <unit> element MUST have a parentSI attribute — a QName referencing the SI unit it derives from. Per the unit-dictionary convention spec.

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, _path) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/chemicalml/convention/unit_dictionary/constraints/unit_must_have_parent_si.rb', line 14

def check_node(node, _path)
  return [] unless node.parent_si.to_s.strip.empty?

  [violation(path: yield_path(node),
             message: "unit #{node.id.inspect} must have a parentSI attribute " \
                      '(QName referencing the parent SI unit)')]
end