Class: Planter::Validator::Result
- Inherits:
-
Object
- Object
- Planter::Validator::Result
- Defined in:
- lib/planter/validator.rb
Overview
Structured validation result containing fatal errors and non-fatal warnings.
Instance Attribute Summary collapse
-
#errors ⇒ Array<String>
readonly
Fatal validation errors.
-
#warnings ⇒ Array<String>
readonly
Non-fatal validation warnings.
Instance Method Summary collapse
-
#add_error(message) ⇒ Object
Record a fatal validation error.
-
#add_warning(message) ⇒ Object
Record a non-fatal validation warning.
-
#initialize ⇒ Result
constructor
Create an empty validation result.
-
#success? ⇒ Boolean
Whether validation completed without fatal errors.
Constructor Details
#initialize ⇒ Result
Create an empty validation result.
29 30 31 32 |
# File 'lib/planter/validator.rb', line 29 def initialize @errors = [] @warnings = [] end |
Instance Attribute Details
#errors ⇒ Array<String> (readonly)
Fatal validation errors.
19 20 21 |
# File 'lib/planter/validator.rb', line 19 def errors @errors end |
#warnings ⇒ Array<String> (readonly)
Non-fatal validation warnings.
25 26 27 |
# File 'lib/planter/validator.rb', line 25 def warnings @warnings end |
Instance Method Details
#add_error(message) ⇒ Object
Record a fatal validation error.
38 39 40 |
# File 'lib/planter/validator.rb', line 38 def add_error() errors << end |
#add_warning(message) ⇒ Object
Record a non-fatal validation warning.
46 47 48 |
# File 'lib/planter/validator.rb', line 46 def add_warning() warnings << end |
#success? ⇒ Boolean
Whether validation completed without fatal errors.
54 55 56 |
# File 'lib/planter/validator.rb', line 54 def success? errors.empty? end |