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