Class: Chemicalml::Convention::UnitDictionary::Constraints::UnitListMustHaveNamespace
- Inherits:
-
Constraint::NodeConstraint
- Object
- Constraint
- Constraint::NodeConstraint
- Chemicalml::Convention::UnitDictionary::Constraints::UnitListMustHaveNamespace
- Defined in:
- lib/chemicalml/convention/unit_dictionary/constraints/unit_list_must_have_namespace.rb
Overview
A <unitList> element MUST have a namespace attribute
whose value is a valid URI defining the scope within which
the unit ids are unique. SHOULD end with / or #.
Instance Method Summary collapse
Methods inherited from Constraint::NodeConstraint
Instance Method Details
#check_node(node, path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/chemicalml/convention/unit_dictionary/constraints/unit_list_must_have_namespace.rb', line 12 def check_node(node, path) violations = [] ns = node.namespace.to_s if ns.empty? violations << violation(path: path.join('/'), message: 'unitList must have a namespace attribute') elsif !ns.end_with?('/', '#') violations << violation(path: path.join('/'), message: "unitList namespace #{ns.inspect} should end with / or #", severity: :warning) end violations end |