Class: Lutaml::Xsd::TargetNamespaceRule

Inherits:
ValidationRule show all
Defined in:
lib/lutaml/xsd/xsd_spec_validator.rb

Overview

Validates target namespace requirements

Instance Attribute Summary

Attributes inherited from ValidationRule

#version

Instance Method Summary collapse

Methods inherited from ValidationRule

#initialize

Constructor Details

This class inherits a constructor from Lutaml::Xsd::ValidationRule

Instance Method Details

#validate(repository) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/lutaml/xsd/xsd_spec_validator.rb', line 76

def validate(repository)
  errors = []
  warnings = []

  get_schemas(repository).each do |schema_file, schema|
    # Check if target namespace is properly defined
    if schema.target_namespace.nil? || schema.target_namespace.empty?
      warnings << "Schema #{File.basename(schema_file)} has no target namespace"
    elsif !%r{^https?://}.match?(schema.target_namespace)
      warnings << "Schema #{File.basename(schema_file)} target namespace '#{schema.target_namespace}' is not a URI"
    end
  end

  { errors: errors, warnings: warnings }
end