Class: Chemicalml::Convention::SimpleUnit::Constraints::RootMustBeUnitList

Inherits:
Constraint::DocumentConstraint show all
Defined in:
lib/chemicalml/convention/simple_unit/constraints/root_must_be_unit_list.rb

Overview

The root of a simpleUnit document MUST be a <unitList> declaring convention="convention:simpleUnit". Any other root shape is rejected.

Instance Method Summary collapse

Instance Method Details

#check(document) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/chemicalml/convention/simple_unit/constraints/root_must_be_unit_list.rb', line 12

def check(document)
  return [] if document.is_a?(Chemicalml::Cml::Role::UnitList) &&
               document.convention == 'convention:simpleUnit'

  [violation(path: '/',
             message: 'simpleUnit root must be <unitList> declaring ' \
                      'convention="convention:simpleUnit"')]
end