Class: Chemicalml::Convention::UnitDictionary::Constraints::UnitMustHaveTitle

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

Overview

A <unit> element MUST have a title attribute (the full human-readable name of the unit). 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_title.rb', line 14

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

  [violation(path: yield_path(node),
             message: "unit #{node.id.inspect} must have a title attribute " \
                      '(the full human-readable name of the unit)')]
end