Sha256: fa44887798fe526832ca22435eea72da4485851feeee42b0c6483aea28c04769

Contents?: true

Size: 686 Bytes

Versions: 12

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

require "dry/monads/result"

module Dry
  module Validation
    # Monad extension for contract results
    #
    # @example
    #   Dry::Validation.load_extensions(:monads)
    #
    #   contract = Dry::Validation::Contract.build do
    #     schema do
    #       required(:name).filled(:string)
    #     end
    #   end
    #
    #   contract.call(name: nil).to_monad
    #
    # @api public
    class Result
      include Dry::Monads::Result::Mixin

      # Returns a result monad
      #
      # @return [Dry::Monads::Result]
      #
      # @api public
      def to_monad
        success? ? Success(self) : Failure(self)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dry-validation-1.9.0 lib/dry/validation/extensions/monads.rb
dry-validation-1.8.1 lib/dry/validation/extensions/monads.rb
dry-validation-1.8.0 lib/dry/validation/extensions/monads.rb
dry-validation-1.7.0 lib/dry/validation/extensions/monads.rb
dry-validation-1.6.0 lib/dry/validation/extensions/monads.rb
dry-validation-1.5.6 lib/dry/validation/extensions/monads.rb
dry-validation-1.5.5 lib/dry/validation/extensions/monads.rb
dry-validation-1.5.4 lib/dry/validation/extensions/monads.rb
dry-validation-1.5.3 lib/dry/validation/extensions/monads.rb
dry-validation-1.5.2 lib/dry/validation/extensions/monads.rb
dry-validation-1.5.1 lib/dry/validation/extensions/monads.rb
dry-validation-1.5.0 lib/dry/validation/extensions/monads.rb