Class: Lutaml::Qea::Validation::ValidationEngine
- Inherits:
-
Object
- Object
- Lutaml::Qea::Validation::ValidationEngine
- Defined in:
- lib/lutaml/qea/validation/validation_engine.rb
Overview
Main orchestrator for the validation system Coordinates all validators and consolidates results
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
-
#initialize(document, database: nil, **options) ⇒ ValidationEngine
constructor
Creates a new validation engine.
-
#register_validator(name, validator_class) ⇒ void
Registers a custom validator.
-
#valid?(validators: nil) ⇒ Boolean
Checks if validation passed (no errors).
-
#validate(validators: nil) ⇒ ValidationResult
Runs validation using two-phase architecture.
-
#validate_and_display(validators: nil, formatter: :text) ⇒ ValidationResult
Validates and displays the result.
-
#validate_qea_database(context, validators = nil) ⇒ ValidationResult
Validates QEA database integrity.
-
#validate_uml_tree(context, validators = nil) ⇒ ValidationResult
Validates UML document tree structure.
Constructor Details
#initialize(document, database: nil, **options) ⇒ ValidationEngine
Creates a new validation engine
29 30 31 32 33 34 35 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 29 def initialize(document, database: nil, **) @document = document @database = database @options = @registry = ValidatorRegistry.new setup_default_validators end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
18 19 20 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 18 def database @database end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
18 19 20 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 18 def document @document end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 18 def @options end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
18 19 20 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 18 def registry @registry end |
Instance Method Details
#register_validator(name, validator_class) ⇒ void
This method returns an undefined value.
Registers a custom validator
152 153 154 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 152 def register_validator(name, validator_class) @registry.register(name, validator_class) end |
#valid?(validators: nil) ⇒ Boolean
Checks if validation passed (no errors)
160 161 162 163 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 160 def valid?(validators: nil) result = validate(validators: validators) !result.has_errors? end |
#validate(validators: nil) ⇒ ValidationResult
Runs validation using two-phase architecture
Phase 1: QEA Database Integrity Validation
-
Validates EA database schema constraints
-
Checks referential integrity
-
Detects orphaned records
-
Finds circular references
Phase 2: UML Tree Structure Validation
-
Validates transformed UML document tree
-
Checks proper nesting
-
Validates duplicate names
-
Verifies type references
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 54 def validate(validators: nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength result = ValidationResult.new context = build_context context[:result] = result # Phase 1: QEA Database Validation phase1_result = validate_qea_database(context, validators) # Phase 2: UML Tree Validation phase2_result = validate_uml_tree(context, validators) # Merge results phase1_result..each { |msg| result. << msg } phase2_result..each { |msg| result. << msg } filter_result(result) end |
#validate_and_display(validators: nil, formatter: :text) ⇒ ValidationResult
Validates and displays the result
141 142 143 144 145 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 141 def validate_and_display(validators: nil, formatter: :text) result = validate(validators: validators) display_result(result, formatter) result end |
#validate_qea_database(context, validators = nil) ⇒ ValidationResult
Validates QEA database integrity
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 77 def validate_qea_database(context, validators = nil) # rubocop:disable Metrics/MethodLength result = ValidationResult.new db_context = context.merge(result: result) database_validators = %i[ referential_integrity orphan circular_reference package ] validator_names = if validators (database_validators & validators) else database_validators end validator_names.each do |name| next unless @registry.registered?(name) @registry.validate(name, db_context) end result end |
#validate_uml_tree(context, validators = nil) ⇒ ValidationResult
Validates UML document tree structure
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/lutaml/qea/validation/validation_engine.rb', line 108 def validate_uml_tree(context, validators = nil) # rubocop:disable Metrics/MethodLength result = ValidationResult.new uml_context = context.merge(result: result) uml_validators = %i[ document_structure class attribute operation association diagram ] validator_names = if validators (uml_validators & validators) else uml_validators end validator_names.each do |name| next unless @registry.registered?(name) @registry.validate(name, uml_context) end result end |