Class: LlmDocsBuilder::Validator
- Inherits:
-
Object
- Object
- LlmDocsBuilder::Validator
- Defined in:
- lib/llm_docs_builder/validator.rb
Overview
Validates llms.txt content against the llms.txt specification
Ensures that llms.txt content follows proper formatting rules including:
-
Required H1 title header
-
Optional description blockquote
-
Proper section ordering (Documentation, Examples, Optional)
-
Valid markdown syntax and link formats
-
File size and line length limits
Constant Summary collapse
- REQUIRED_SECTIONS =
Required sections that must appear in llms.txt
['# '].freeze
- OPTIONAL_SECTIONS =
Optional sections that may appear in llms.txt
['> ', '## Documentation', '## Examples', '## Optional'].freeze
- MAX_LINE_LENGTH =
Maximum length for a single line in characters
120- MAX_FILE_SIZE =
Maximum file size in bytes
50_000
Instance Attribute Summary collapse
-
#content ⇒ String
readonly
The llms.txt content being validated.
-
#errors ⇒ Array<String>
readonly
Array of validation error messages.
Instance Method Summary collapse
-
#initialize(content) ⇒ Validator
constructor
Initialize a new validator.
-
#valid? ⇒ Boolean
Check if content is valid.
-
#validate! ⇒ Boolean
Validate content and return result.
Constructor Details
#initialize(content) ⇒ Validator
Initialize a new validator
41 42 43 44 |
# File 'lib/llm_docs_builder/validator.rb', line 41 def initialize(content) @content = content @errors = [] end |
Instance Attribute Details
#content ⇒ String (readonly)
Returns the llms.txt content being validated.
21 22 23 |
# File 'lib/llm_docs_builder/validator.rb', line 21 def content @content end |
#errors ⇒ Array<String> (readonly)
Returns array of validation error messages.
24 25 26 |
# File 'lib/llm_docs_builder/validator.rb', line 24 def errors @errors end |
Instance Method Details
#valid? ⇒ Boolean
Check if content is valid
Runs all validation checks and returns whether the content is valid. Use #errors to access validation error messages.
52 53 54 55 |
# File 'lib/llm_docs_builder/validator.rb', line 52 def valid? validate! errors.empty? end |
#validate! ⇒ Boolean
Validate content and return result
Runs all validation checks, populates #errors array, and returns whether the content is valid.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/llm_docs_builder/validator.rb', line 63 def validate! @errors = [] validate_required_sections validate_structure validate_markdown_syntax validate_links validate_file_size errors.empty? end |