Class: Zizia::Validator Abstract
- Inherits:
-
Object
- Object
- Zizia::Validator
- Defined in:
- lib/zizia/validator.rb
Overview
A null validator; always returns an empty error collection
Validators are used to ensure the correctness of input to a parser. Each validator must respond to ‘#validate` and return a collection of errors found during validation. If the input is valid, this collection must be empty. Otherwise, it contains any number of `Validator::Error` structs which should be logged to Rails.logger by the validator.
The validation process accepts an entire ‘Parser` and is free to inspect the input `#file` content, or view its individual `#records`.
The base class provides infrastructure for the key behavior, relying on a private ‘#run_validation` method to provide the core behavior. In most cases implementers will want to simply override this method.
Direct Known Subclasses
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
-
#validate(parser:) ⇒ Enumerator<Error>
A collection of errors found in validation.
Instance Method Details
#validate(parser:) ⇒ Enumerator<Error>
Returns a collection of errors found in validation.
87 88 89 90 91 |
# File 'lib/zizia/validator.rb', line 87 def validate(parser:) run_validation(parser: parser).tap do |errors| errors.map { |error| Rails.logger.error "[zizia] #{error}" } end end |