Class: Lutaml::Xsd::BasePackageConfig
- Inherits:
-
Model::Serializable
- Object
- Model::Serializable
- Lutaml::Xsd::BasePackageConfig
- Defined in:
- lib/lutaml/xsd/base_package_config.rb
Overview
Configuration for a single base package with conflict resolution settings
Instance Method Summary collapse
-
#include_schema?(schema_path) ⇒ Boolean
Apply schema filtering.
-
#valid? ⇒ Boolean
Check if configuration is valid.
-
#validate ⇒ ValidationResult
Validate configuration.
-
#validate! ⇒ Object
Raise error if invalid.
Instance Method Details
#include_schema?(schema_path) ⇒ Boolean
Apply schema filtering
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/lutaml/xsd/base_package_config.rb', line 95 def include_schema?(schema_path) return false if exclude_schemas&.any? && matches_patterns?(schema_path, exclude_schemas) if include_only_schemas&.any? return matches_patterns?(schema_path, include_only_schemas) end true end |
#valid? ⇒ Boolean
Check if configuration is valid
82 83 84 |
# File 'lib/lutaml/xsd/base_package_config.rb', line 82 def valid? validate.valid? end |
#validate ⇒ ValidationResult
Validate configuration
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/lutaml/xsd/base_package_config.rb', line 29 def validate errors = [] # Package path validation if package.nil? || package.empty? errors << ValidationError.create( field: :package, message: "Package path is required", constraint: "presence", ) end # Conflict resolution validation valid_strategies = ["keep", "override", "error"] unless valid_strategies.include?(conflict_resolution) errors << ValidationError.create( field: :conflict_resolution, message: "Invalid conflict resolution strategy", value: conflict_resolution, constraint: "inclusion: #{valid_strategies.join(', ')}", ) end # Priority validation if priority.negative? errors << ValidationError.create( field: :priority, message: "Priority must be non-negative", value: priority, constraint: ">= 0", ) end # Namespace remapping validation namespace_remapping&.each_with_index do |remap, idx| remap_result = remap.validate if remap_result.invalid? remap_result.errors.each do |error| errors << ValidationError.create( field: "namespace_remapping[#{idx}].#{error.field}", message: error., value: error.value, constraint: error.constraint, ) end end end errors.empty? ? ValidationResult.success : ValidationResult.failure(errors) end |
#validate! ⇒ Object
Raise error if invalid
88 89 90 |
# File 'lib/lutaml/xsd/base_package_config.rb', line 88 def validate! validate.validate! end |