Class: Asimov::Utils::JsonlValidator
- Inherits:
-
Object
- Object
- Asimov::Utils::JsonlValidator
- Defined in:
- lib/asimov/utils/jsonl_validator.rb
Overview
Validates that a file is a JSONL file. Subclassed by more specific file validators.
Direct Known Subclasses
ClassificationsFileValidator, TextEntryFileValidator, TrainingFileValidator
Instance Method Summary collapse
-
#validate(io) ⇒ Object
Validate that the IO object (typically a File) is properly formatted.
Instance Method Details
#validate(io) ⇒ Object
Validate that the IO object (typically a File) is properly formatted. Entry method for this class and its subclasses. Required format will depend on the class.
are to be format checked.
18 19 20 21 22 23 |
# File 'lib/asimov/utils/jsonl_validator.rb', line 18 def validate(io) io.each_line.with_index { |line, idx| validate_line(line, idx) } true rescue JSON::ParserError raise JsonlFileCannotBeParsedError, "Expected file to have the JSONL format." end |