Class: Lutaml::Xsd::PackageValidator

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

Overview

Validates that a schema repository package is fully resolved Checks that all type, element, attribute, and group references are resolvable within the package

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository) ⇒ PackageValidator

Returns a new instance of PackageValidator.



11
12
13
14
15
# File 'lib/lutaml/xsd/package_validator.rb', line 11

def initialize(repository)
  @repository = repository
  @errors = []
  @warnings = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'lib/lutaml/xsd/package_validator.rb', line 9

def errors
  @errors
end

#repositoryObject (readonly)

Returns the value of attribute repository.



9
10
11
# File 'lib/lutaml/xsd/package_validator.rb', line 9

def repository
  @repository
end

#warningsObject (readonly)

Returns the value of attribute warnings.



9
10
11
# File 'lib/lutaml/xsd/package_validator.rb', line 9

def warnings
  @warnings
end

Instance Method Details

#validate_full_resolutionHash

Validate that all references in the package are fully resolved

Returns:

  • (Hash)

    Validation results with errors, warnings, and statistics



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/lutaml/xsd/package_validator.rb', line 19

def validate_full_resolution
  @errors = []
  @warnings = []

  # Check all type references
  validate_type_references

  # Check all element references
  validate_element_references

  # Check all attribute references
  validate_attribute_references

  # Check all group references
  validate_group_references

  # Check all attribute group references
  validate_attribute_group_references

  # Check imports/includes are all resolved
  validate_imports_and_includes

  {
    valid: @errors.empty?,
    errors: @errors,
    warnings: @warnings,
    statistics: {
      types_checked: count_type_references,
      elements_checked: count_element_references,
      attributes_checked: count_attribute_references,
      groups_checked: count_group_references,
      attribute_groups_checked: count_attribute_group_references,
      all_resolved: @errors.empty?,
    },
  }
end