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)


268
269
270
271
272
273
# File 'lib/dry/monads/validated.rb', line 268

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)


251
252
253
254
255
256
# File 'lib/dry/monads/validated.rb', line 251

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

  Valid.new(v)
end