Class: Glossarist::Validation::Rules::PartitiveRelationRule
- Defined in:
- lib/glossarist/validation/rules/partitive_relation_rule.rb
Overview
Validates semantic invariants of PartitiveRelation entries that the model constructor does NOT enforce. Specifically:
- error when a relation has fewer than 2 partitives
(ISO 704: "two or more"; single binary should use
has_part edge instead)
- error when two relations share the same comprehensive
AND the same non-nil criterion (duplicate decomposition;
ISO 12620 coordinate-concept coherence)
- warning when a relation has no criterion (cannot
distinguish from siblings sharing the comprehensive)
- warning when multiplicity is not the default compulsory
(encourages explicit statement of optional/multiple)
- error when ExternalConcept (status: external) lacks
at least one designation
The model constructor already rejects empty comprehensive, empty partitives list, self-loops, invalid enum values.
Instance Method Summary collapse
- #applicable?(context) ⇒ Boolean
- #category ⇒ Object
- #check(context) ⇒ Object
- #code ⇒ Object
- #scope ⇒ Object
- #severity ⇒ Object
Methods inherited from Base
Instance Method Details
#applicable?(context) ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 30 def applicable?(context) concept = context.concept return false unless concept.is_a?(V3::ManagedConcept) concept.partitive_relations&.any? || external?(concept) end |
#category ⇒ Object
26 |
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 26 def category = :schema |
#check(context) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 37 def check(context) concept = context.concept fname = context.file_name issues = [] return issues unless concept.is_a?(V3::ManagedConcept) relations = Array(concept.partitive_relations) relations.each_with_index do |rel, idx| check_cardinality(rel, idx, fname, issues) check_criterion_present(rel, idx, fname, issues) check_member_multiplicity(rel, idx, fname, issues) end check_duplicate_decomposition(relations, fname, issues) check_external_concept(concept, fname, issues) issues end |
#code ⇒ Object
25 |
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 25 def code = "GLS-221" |
#scope ⇒ Object
28 |
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 28 def scope = :concept |
#severity ⇒ Object
27 |
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 27 def severity = "error" |