Class: Chemicalml::Convention::Dictionary::Constraints::EntryMustHaveIdAndTerm

Inherits:
Constraint::NodeConstraint show all
Defined in:
lib/chemicalml/convention/dictionary/constraints/entry_must_have_id_and_term.rb

Overview

Every entry MUST have an id and a term attribute per the dictionary convention.

Instance Method Summary collapse

Methods inherited from Constraint::NodeConstraint

#check

Instance Method Details

#check_node(node, path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/chemicalml/convention/dictionary/constraints/entry_must_have_id_and_term.rb', line 11

def check_node(node, path)

  violations = []
  if node.id.to_s.empty?
    violations << violation(path: path.join('/'),
                            message: 'entry must have an id attribute')
  end
  if node.term.to_s.empty?
    violations << violation(path: path.join('/'),
                            message: 'entry must have a term attribute')
  end
  violations
end