Class: Chemicalml::Convention::UnitTypeDictionary::Constraints::UnitTypeIdMustMatchPattern
- Inherits:
-
Constraint::NodeConstraint
- Object
- Constraint
- Constraint::NodeConstraint
- Chemicalml::Convention::UnitTypeDictionary::Constraints::UnitTypeIdMustMatchPattern
- Defined in:
- lib/chemicalml/convention/unit_type_dictionary/constraints/unit_type_id_must_match_pattern.rb
Overview
A <unitType> id MUST match [A-Za-z][A-Za-z0-9._-]*.
Constant Summary collapse
- PATTERN =
/\A[A-Za-z][A-Za-z0-9._-]*\z/
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 |
# File 'lib/chemicalml/convention/unit_type_dictionary/constraints/unit_type_id_must_match_pattern.rb', line 12 def check_node(node, path) id = node.id.to_s return [] if id.empty? return [] if id.match?(PATTERN) [violation(path: path.join('/'), message: "unitType id #{id.inspect} must match [A-Za-z][A-Za-z0-9._-]*")] end |