Module: Uniword::Validation::Engine
- Defined in:
- lib/uniword/validation/engine.rb
Overview
The single validation engine.
Runs the rules registered in Rules::Registry against a validation context and returns Report::ValidationIssue results. One engine, two front-ends:
- On-disk (post-save): Rules::DocumentContext wraps the DOCX package; driven by Validators::DocumentSemanticsValidator (verify layer 3).
- In-memory (pre-save): Rules::ModelContext wraps the document model;
driven by Wordprocessingml::DocumentRoot#valid? and CLI
validate.
Rules declare which context they consume via Rules::Base#context_type (:package or :model); only matching rules run.
Class Method Summary collapse
-
.run(context, rules: Rules::Registry.all) ⇒ Array<Report::ValidationIssue>
Run every rule matching the context's type.
Class Method Details
.run(context, rules: Rules::Registry.all) ⇒ Array<Report::ValidationIssue>
Run every rule matching the context's type.
25 26 27 28 29 30 31 32 |
# File 'lib/uniword/validation/engine.rb', line 25 def self.run(context, rules: Rules::Registry.all) rules.each_with_object([]) do |rule, issues| next unless rule.context_type == context.context_type next unless rule.applicable?(context) issues.concat(rule.check(context)) end end |