Class: Dry::Monads::Validated Private
- Inherits:
-
Object
- Object
- Dry::Monads::Validated
- Defined in:
- lib/dry/monads/validated.rb,
lib/dry/monads/maybe.rb,
lib/dry/monads/result.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Validated is similar to Result and represents an outcome of a validation. The difference between Validated and Result is that the former implements ‘#apply` in a way that concatenates errors. This means that the error type has to have `+` implemented (be a semigroup). This plays nice with arrays and lists. Also, List<Validated>#traverse implicitly uses a block that wraps errors with a list so that you don’t have to do it manually.
Defined Under Namespace
Modules: Mixin Classes: Invalid, Valid
Class Method Summary collapse
-
.pure(value = Undefined, &block) ⇒ Object
private
Wraps a value with ‘Valid`.
Instance Method Summary collapse
-
#bind ⇒ Object
private
Bind/flat_map is not implemented.
-
#to_monad ⇒ Validated::Valid, Validated::Invalid
private
Returns self.
Class Method Details
.pure(value) ⇒ Validated::Valid .pure(&block) ⇒ Validated::Valid
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wraps a value with ‘Valid`.
34 35 36 |
# File 'lib/dry/monads/validated.rb', line 34 def pure(value = Undefined, &block) Valid.new(Undefined.default(value, block)) end |
Instance Method Details
#bind ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Bind/flat_map is not implemented
48 49 50 51 52 |
# File 'lib/dry/monads/validated.rb', line 48 def bind(*) # See https://typelevel.org/cats/datatypes/validated.html for details on why raise NotImplementedError, "Validated is not a monad because it would violate the monad laws" end |
#to_monad ⇒ Validated::Valid, Validated::Invalid
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns self.
42 43 44 |
# File 'lib/dry/monads/validated.rb', line 42 def to_monad self end |