Class: Lutaml::Xsd::Validation::Rules::TypeValidationRule

Inherits:
ValidationRule
  • Object
show all
Defined in:
lib/lutaml/xsd/validation/rules/type_validation_rule.rb

Overview

TypeValidationRule validates element types

This rule checks:

  • Resolves element type from schema
  • Validates simple type content
  • Validates complex type content
  • Delegates to base type validators and facet validators

Based on Jing validator type validation algorithm.

Examples:

Using the rule

rule = TypeValidationRule.new
rule.validate(xml_element, schema_element, collector)

See Also:

  • Type Validation

Constant Summary

Constants inherited from ValidationRule

ValidationRule::CATEGORIES

Instance Attribute Summary

Attributes inherited from ValidationRule

#options

Instance Method Summary collapse

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

#categorySymbol

Rule category



28
29
30
# File 'lib/lutaml/xsd/validation/rules/type_validation_rule.rb', line 28

def category
  :type
end

#descriptionString

Rule description



35
36
37
# File 'lib/lutaml/xsd/validation/rules/type_validation_rule.rb', line 35

def description
  "Validates element content against XSD type definitions"
end

#validate(xml_element, schema_element, collector) ⇒ void

This method returns an undefined value.

Validate element type

Validates the element's content against its type definition, handling both simple and complex types.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/lutaml/xsd/validation/rules/type_validation_rule.rb', line 49

def validate(xml_element, schema_element, collector)
  return unless schema_element

  type_def = resolve_element_type(schema_element)
  return unless type_def

  case type_def
  when Lutaml::Xsd::SimpleType
    validate_simple_type_content(xml_element, type_def, collector)
  when Lutaml::Xsd::ComplexType
    validate_complex_type_content(xml_element, type_def, collector)
  else
    # Handle built-in types
    validate_builtin_type(xml_element, type_def, collector)
  end
end