Module: Dry::Monads::Validated::Mixin::Constructors Private

Included in:
Dry::Monads, Dry::Monads::Validated::Mixin
Defined in:
lib/dry/monads/validated.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Actual constructor methods

Instance Method Summary collapse

Instance Method Details

#Invalid(value) ⇒ Valdated::Invalid #Invalid(&block) ⇒ Valdated::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.

Invalid constructor

Overloads:

  • #Invalid(value) ⇒ Valdated::Invalid

    Parameters:

    • value (Object)

    Returns:

    • (Valdated::Invalid)
  • #Invalid(&block) ⇒ Valdated::Invalid

    Parameters:

    • block (Proc)

    Returns:

    • (Valdated::Invalid)

Raises:

  • (ArgumentError)


256
257
258
259
260
261
# File 'lib/dry/monads/validated.rb', line 256

def Invalid(value = Undefined, &block)
  v = Undefined.default(value, block)
  raise ArgumentError, "No value given" if !value.nil? && v.nil?

  Invalid.new(v, RightBiased::Left.trace_caller)
end

#Valid(value) ⇒ Valdated::Valid #Valid(&block) ⇒ Valdated::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.

Valid constructor

Overloads:

  • #Valid(value) ⇒ Valdated::Valid

    Parameters:

    • value (Object)

    Returns:

    • (Valdated::Valid)
  • #Valid(&block) ⇒ Valdated::Valid

    Parameters:

    • block (Proc)

    Returns:

    • (Valdated::Valid)

Raises:

  • (ArgumentError)


239
240
241
242
243
244
# File 'lib/dry/monads/validated.rb', line 239

def Valid(value = Undefined, &block)
  v = Undefined.default(value, block)
  raise ArgumentError, "No value given" if !value.nil? && v.nil?

  Valid.new(v)
end