Class: Ukiryu::Models::ValidationResult
- Inherits:
-
Object
- Object
- Ukiryu::Models::ValidationResult
- Defined in:
- lib/ukiryu/models/validation_result.rb
Overview
Result of validating a tool profile against the schema
Contains validation status and any errors found during validation.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#tool_name ⇒ Object
readonly
Returns the value of attribute tool_name.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
Class Method Summary collapse
-
.invalid(tool_name, errors) ⇒ ValidationResult
Create an invalid result with errors.
-
.not_found(tool_name) ⇒ ValidationResult
Create a result for a tool not found.
-
.valid(tool_name) ⇒ ValidationResult
Create a valid result (no errors).
Instance Method Summary collapse
-
#initialize(tool_name:, valid:, errors: []) ⇒ ValidationResult
constructor
Create a new validation result.
-
#invalid? ⇒ Boolean
Check if validation failed.
-
#not_found? ⇒ Boolean
Check if tool was not found.
-
#status_message ⇒ String
Get a human-readable status message.
-
#valid? ⇒ Boolean
Check if validation passed.
Constructor Details
#initialize(tool_name:, valid:, errors: []) ⇒ ValidationResult
Create a new validation result
16 17 18 19 20 |
# File 'lib/ukiryu/models/validation_result.rb', line 16 def initialize(tool_name:, valid:, errors: []) @tool_name = tool_name @valid = valid @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/ukiryu/models/validation_result.rb', line 9 def errors @errors end |
#tool_name ⇒ Object (readonly)
Returns the value of attribute tool_name.
9 10 11 |
# File 'lib/ukiryu/models/validation_result.rb', line 9 def tool_name @tool_name end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
9 10 11 |
# File 'lib/ukiryu/models/validation_result.rb', line 9 def valid @valid end |
Class Method Details
.invalid(tool_name, errors) ⇒ ValidationResult
Create an invalid result with errors
35 36 37 |
# File 'lib/ukiryu/models/validation_result.rb', line 35 def self.invalid(tool_name, errors) new(tool_name: tool_name, valid: false, errors: errors) end |
.not_found(tool_name) ⇒ ValidationResult
Create a result for a tool not found
43 44 45 |
# File 'lib/ukiryu/models/validation_result.rb', line 43 def self.not_found(tool_name) new(tool_name: tool_name, valid: false, errors: ['Tool not found']) end |
.valid(tool_name) ⇒ ValidationResult
Create a valid result (no errors)
26 27 28 |
# File 'lib/ukiryu/models/validation_result.rb', line 26 def self.valid(tool_name) new(tool_name: tool_name, valid: true, errors: []) end |
Instance Method Details
#invalid? ⇒ Boolean
Check if validation failed
68 69 70 |
# File 'lib/ukiryu/models/validation_result.rb', line 68 def invalid? !@valid end |
#not_found? ⇒ Boolean
Check if tool was not found
75 76 77 |
# File 'lib/ukiryu/models/validation_result.rb', line 75 def not_found? @errors == ['Tool not found'] end |
#status_message ⇒ String
Get a human-readable status message
50 51 52 53 54 55 56 |
# File 'lib/ukiryu/models/validation_result.rb', line 50 def if valid? '✓ Valid' else "✗ Invalid (#{errors.size} error#{errors.size == 1 ? '' : 's'})" end end |
#valid? ⇒ Boolean
Check if validation passed
61 62 63 |
# File 'lib/ukiryu/models/validation_result.rb', line 61 def valid? @valid end |