Class: Chemicalml::Convention::UnitDictionary::Constraints::UnitParentSiShouldResolve
- Inherits:
-
Constraint::NodeConstraint
- Object
- Constraint
- Constraint::NodeConstraint
- Chemicalml::Convention::UnitDictionary::Constraints::UnitParentSiShouldResolve
- Defined in:
- lib/chemicalml/convention/unit_dictionary/constraints/unit_parent_si_should_resolve.rb
Overview
A <unit>'s parentSI attribute SHOULD reference a unit
that exists in a built-in dictionary (typically the SI
dictionary). Catches typos like parentSI="si:metr".
Cross-component check parallel to UnitUnitTypeShouldResolve and the molecular convention's DictRefShouldResolve.
Instance Method Summary collapse
Methods inherited from Constraint::NodeConstraint
Instance Method Details
#check_node(node, _path) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chemicalml/convention/unit_dictionary/constraints/unit_parent_si_should_resolve.rb', line 17 def check_node(node, _path) parent_si = node.parent_si.to_s.strip return [] if parent_si.empty? return [] if resolves?(parent_si) [violation(path: yield_path(node), message: "unit #{node.id.inspect} parentSI #{parent_si.inspect} does not " \ 'resolve against any built-in unit dictionary', severity: :warning, value: parent_si)] end |