Module: Mayak::ValidationResult
- Extended by:
- T::Generic, T::Sig
- Includes:
- Kernel
- Defined in:
- lib/mayak/validation_result.rb
Defined Under Namespace
Constant Summary collapse
- Error =
type_member(:out)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_exceptions(exceptions) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/mayak/validation_result.rb', line 52 def self.from_exceptions(exceptions) if exceptions.empty? ::Mayak::ValidationResult::Valid[StandardError].new else ::Mayak::ValidationResult::Invalid[StandardError].new(errors: exceptions) end end |
.from_strings(strings) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/mayak/validation_result.rb', line 61 def self.from_strings(strings) if strings.empty? ::Mayak::ValidationResult::Valid[String].new else ::Mayak::ValidationResult::Invalid[String].new(errors: strings) end end |
Instance Method Details
#invalid? ⇒ Boolean
34 35 36 |
# File 'lib/mayak/validation_result.rb', line 34 def invalid? !valid? end |
#map_errors(&blk) ⇒ Object
25 26 |
# File 'lib/mayak/validation_result.rb', line 25 def map_errors(&blk) end |
#on_valid(&blk) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/mayak/validation_result.rb', line 43 def on_valid(&blk) if is_a?(::Mayak::ValidationResult::Valid) blk.call else self end end |
#valid? ⇒ Boolean
29 30 31 |
# File 'lib/mayak/validation_result.rb', line 29 def valid? is_a?(::Mayak::ValidationResult::Valid) end |