Class: Roast::Workflow::Validators::SchemaValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- Roast::Workflow::Validators::SchemaValidator
- Defined in:
- lib/roast/workflow/validators/schema_validator.rb
Overview
Validates workflow configuration against JSON schema
Instance Attribute Summary collapse
-
#parsed_yaml ⇒ Object
readonly
Returns the value of attribute parsed_yaml.
Attributes inherited from BaseValidator
Instance Method Summary collapse
-
#initialize(yaml_content, workflow_path = nil) ⇒ SchemaValidator
constructor
rubocop:disable Lint/MissingSuper.
- #validate ⇒ Object
Methods inherited from BaseValidator
Constructor Details
#initialize(yaml_content, workflow_path = nil) ⇒ SchemaValidator
rubocop:disable Lint/MissingSuper
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/roast/workflow/validators/schema_validator.rb', line 10 def initialize(yaml_content, workflow_path = nil) # rubocop:disable Lint/MissingSuper @yaml_content = yaml_content&.strip || "" @workflow_path = workflow_path @errors = [] @warnings = [] begin @parsed_yaml = @yaml_content.empty? ? {} : YAML.safe_load(@yaml_content) rescue Psych::SyntaxError => e @errors << format_yaml_error(e) @parsed_yaml = {} end end |
Instance Attribute Details
#parsed_yaml ⇒ Object (readonly)
Returns the value of attribute parsed_yaml.
8 9 10 |
# File 'lib/roast/workflow/validators/schema_validator.rb', line 8 def parsed_yaml @parsed_yaml end |
Instance Method Details
#validate ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/roast/workflow/validators/schema_validator.rb', line 24 def validate if @parsed_yaml.empty? @errors << { type: :empty_configuration, message: "Workflow configuration is empty", suggestion: "Provide a valid workflow configuration with required fields: name, tools, and steps", } return end validator = Validator.new(@yaml_content) unless validator.valid? validator.errors.each do |error| @errors << format_schema_error(error) end end end |