class
Amber::Schema::LegacyResult
- Amber::Schema::LegacyResult
- Reference
- Object
Overview
Legacy Result class for backward compatibility This maintains the existing API while using the new Result types internally
Defined in:
amber/schema/result.crConstructors
Class Method Summary
- .failure(errors : Array(Error), original_data : Hash(String, JSON::Any) | Nil = nil)
-
.success(data : Hash(String, JSON::Any))
Factory methods for creating results
Instance Method Summary
-
#add_error(error : Error)
Add an error to the result
-
#add_warning(warning : Warning)
Add a warning (non-fatal issue)
-
#data : Hash(String, JSON::Any) | Nil
Validated and transformed data
-
#error_messages : Array(String)
Get all error messages as strings
- #errors : Array(Error)
-
#errors_by_field : Hash(String, Array(Error))
Get errors grouped by field
- #failure?
-
#original_data : Hash(String, JSON::Any) | Nil
Original input data (for debugging)
-
#success : Bool
Status of the validation/parsing operation
-
#success? : Bool
Check if validation/parsing was successful
-
#to_h
Convert result to a hash suitable for JSON response
-
#to_typed_result : Success(Hash(String, JSON::Any)) | Failure(Hash(String, JSON::Any))
Convert to new Result type - only works for types that can be constructed from Hash
- #warnings : Array(Warning)
Constructor Detail
def self.new(success : Bool, data : Hash(String, JSON::Any) | Nil = nil, original_data : Hash(String, JSON::Any) | Nil = nil)
#
Class Method Detail
Factory methods for creating results
Instance Method Detail
Original input data (for debugging)
Convert to new Result type - only works for types that can be constructed from Hash