Class: Uniword::Plugin::Validator
- Inherits:
-
Object
- Object
- Uniword::Plugin::Validator
- Defined in:
- lib/uniword/plugin/validator.rb
Overview
Base class for plugin-provided validation rules. Subclasses
implement #check(document) (yields findings).
Open/closed: adding a new validator = subclassing + calling
Registry.register_validator.
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
Validator name (matches the registry key).
-
#severity ⇒ Symbol
readonly
Default severity (:error, :warning, :info).
Instance Method Summary collapse
-
#check(document) {|finding| ... } ⇒ void
Walk the document and yield each finding as a hash.
-
#initialize(name:, severity: :warning) ⇒ Validator
constructor
A new instance of Validator.
Constructor Details
#initialize(name:, severity: :warning) ⇒ Validator
Returns a new instance of Validator.
19 20 21 22 |
# File 'lib/uniword/plugin/validator.rb', line 19 def initialize(name:, severity: :warning) @name = name @severity = severity end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
Returns validator name (matches the registry key).
12 13 14 |
# File 'lib/uniword/plugin/validator.rb', line 12 def name @name end |
#severity ⇒ Symbol (readonly)
Returns default severity (:error, :warning, :info).
15 16 17 |
# File 'lib/uniword/plugin/validator.rb', line 15 def severity @severity end |
Instance Method Details
#check(document) {|finding| ... } ⇒ void
This method returns an undefined value.
Walk the document and yield each finding as a hash.
29 30 31 |
# File 'lib/uniword/plugin/validator.rb', line 29 def check(document) raise NotImplementedError end |