Class: Chemicalml::Convention::Compchem::Constraints::ArrayRules
- Inherits:
-
Chemicalml::Convention::Constraint::NodeConstraint
- Object
- Constraint
- Chemicalml::Convention::Constraint::NodeConstraint
- Chemicalml::Convention::Compchem::Constraints::ArrayRules
- Includes:
- ModulePredicates
- Defined in:
- lib/chemicalml/convention/compchem/constraints/array_rules.rb
Overview
CompChem array value-container rules: MUST have size
attribute (≥ 1); dataType MUST be integer or double;
MUST have units.
Constant Summary collapse
- ALLOWED_TYPES =
%w[xsd:integer xsd:double].freeze
Instance Method Summary collapse
Methods included from ModulePredicates
#calculation_module?, #child_modules_with, #cml_module?, #compchem_root?, #environment_module?, #finalization_module?, #initialization_module?, #job_list_module?, #job_module?
Methods inherited from Chemicalml::Convention::Constraint::NodeConstraint
Instance Method Details
#check_node(node, path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/chemicalml/convention/compchem/constraints/array_rules.rb', line 16 def check_node(node, path) violations = [] if node.size.to_s.empty? || node.size.to_i < 1 violations << violation(path: path.join('/'), message: 'array must have a size attribute (minimum 1)') end unless ALLOWED_TYPES.include?(node.data_type.to_s) violations << violation(path: path.join('/'), message: 'array dataType must be xsd:integer or xsd:double ' \ "(got #{node.data_type.inspect})") end if node.units.to_s.empty? violations << violation(path: path.join('/'), message: 'array must have units (even if dimensionless)') end violations end |