Class: Chemicalml::Convention::Molecular::Constraints::PropertyScalarDataTypeMatchesDictionary
- Inherits:
-
Constraint::NodeConstraint
- Object
- Constraint
- Constraint::NodeConstraint
- Chemicalml::Convention::Molecular::Constraints::PropertyScalarDataTypeMatchesDictionary
- Defined in:
- lib/chemicalml/convention/molecular/constraints/property_scalar_data_type_matches_dictionary.rb
Overview
A <property> with a dictRef whose dictionary entry declares
a dataType SHOULD have a child <scalar> whose dataType
attribute matches. Catches inconsistencies like a property
declaring dictRef="cml:bp" (boiling point, xsd:float) but
carrying a <scalar dataType="xsd:string">.
Warning severity — some dictionaries allow multiple dataTypes.
Instance Method Summary collapse
Methods inherited from Constraint::NodeConstraint
Instance Method Details
#check_node(node, _path) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chemicalml/convention/molecular/constraints/property_scalar_data_type_matches_dictionary.rb', line 18 def check_node(node, _path) dict_ref = node.dict_ref.to_s return [] if dict_ref.empty? entry = lookup_entry(dict_ref) return [] unless entry expected_type = entry.data_type.to_s return [] if expected_type.empty? scalar = node.scalar return [] unless scalar actual_type = scalar.data_type.to_s return [] if actual_type.empty? return [] if actual_type == expected_type [violation(path: yield_path(node), message: "property #{node.id.inspect} dictRef #{dict_ref.inspect} " \ "expects dataType #{expected_type.inspect} but scalar has #{actual_type.inspect}", severity: :warning, value: { expected: expected_type, actual: actual_type }.freeze)] end |