Class: Lutaml::Xsd::Validation::Rules::OccurrenceValidationRule
- Inherits:
-
ValidationRule
- Object
- ValidationRule
- Lutaml::Xsd::Validation::Rules::OccurrenceValidationRule
- Defined in:
- lib/lutaml/xsd/validation/rules/occurrence_validation_rule.rb
Overview
OccurrenceValidationRule validates occurrence constraints
This rule checks:
-
minOccurs constraint is satisfied
-
maxOccurs constraint is satisfied (including unbounded)
-
Element occurrence counts
-
Reports violations with expected vs actual counts
Based on Jing validator occurrence validation algorithm.
Constant Summary
Constants inherited from ValidationRule
Instance Attribute Summary
Attributes inherited from ValidationRule
Instance Method Summary collapse
-
#category ⇒ Symbol
Rule category.
-
#description ⇒ String
Rule description.
-
#validate(parent_element, schema_particle, collector) ⇒ void
Validate occurrence constraints.
Methods inherited from ValidationRule
#applicable?, #disable!, #enable!, #enabled?, #initialize, #inspect, #option, #priority, #to_h, #to_s
Constructor Details
This class inherits a constructor from Lutaml::Xsd::Validation::ValidationRule
Instance Method Details
#category ⇒ Symbol
Rule category
28 29 30 |
# File 'lib/lutaml/xsd/validation/rules/occurrence_validation_rule.rb', line 28 def category :constraint end |
#description ⇒ String
Rule description
35 36 37 |
# File 'lib/lutaml/xsd/validation/rules/occurrence_validation_rule.rb', line 35 def description "Validates minOccurs and maxOccurs constraints on elements" end |
#validate(parent_element, schema_particle, collector) ⇒ void
This method returns an undefined value.
Validate occurrence constraints
Validates that elements appear the correct number of times according to their minOccurs and maxOccurs constraints.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/lutaml/xsd/validation/rules/occurrence_validation_rule.rb', line 49 def validate(parent_element, schema_particle, collector) return unless schema_particle return unless parent_element # Handle different particle types case schema_particle when Lutaml::Xsd::Element validate_element_occurrence(parent_element, schema_particle, collector) when Lutaml::Xsd::Sequence validate_sequence_occurrences(parent_element, schema_particle, collector) when Lutaml::Xsd::Choice validate_choice_occurrences(parent_element, schema_particle, collector) when Lutaml::Xsd::All validate_all_occurrences(parent_element, schema_particle, collector) end end |