Class: Lutaml::Xsd::Validation::ValidationJob

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xsd/validation/validation_job.rb

Overview

ValidationJob executes the validation workflow

This class implements the Command pattern to execute XML validation against XSD schemas. It coordinates the validation process through multiple phases: XML parsing, structure validation, type validation, and constraint validation.

Examples:

Execute a validation job

job = ValidationJob.new(
  xml_content: "<root>...</root>",
  repository: schema_repository,
  rule_registry: rule_registry,
  config: configuration
)
result = job.execute

Instance Method Summary collapse

Constructor Details

#initialize(xml_content:, repository:, rule_registry:, config:) ⇒ ValidationJob

Initialize a new ValidationJob

Raises:

  • (ArgumentError)

    if required parameters are missing



36
37
38
39
40
41
42
43
44
45
# File 'lib/lutaml/xsd/validation/validation_job.rb', line 36

def initialize(xml_content:, repository:, rule_registry:, config:)
  @xml_content = xml_content
  @repository = repository
  @rule_registry = rule_registry
  @config = config
  @result_collector = ResultCollector.new(config)
  @navigator = nil
  @document = nil
  @rule_engine = nil
end

Instance Method Details

#executeValidationResult

Execute the validation workflow

Performs validation in the following order:

  1. Parse XML document
  2. Validate structure (elements, namespaces)
  3. Validate types (simple and complex types)
  4. Validate constraints (occurrences, identity constraints)


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/lutaml/xsd/validation/validation_job.rb', line 56

def execute
  return early_result if should_stop_early?

  parse_xml
  return result_from_collector if should_stop_after_parse?

  validate_structure if @config.feature_enabled?(:validate_types)
  return result_from_collector if should_stop_after_structure?

  validate_types if @config.feature_enabled?(:validate_types)
  return result_from_collector if should_stop_after_types?

  validate_constraints if @config.feature_enabled?(:validate_occurrences)
  return result_from_collector if should_stop_after_constraints?

  result_from_collector
end