Sha256: da1f884733c50e1650a1a95f41d0d4be18c53a002cd6e82cc0da696f5c6f820f

Contents?: true

Size: 759 Bytes

Versions: 7

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

require "dry/schema/message/or/single_path"
require "dry/schema/message/or/multi_path"

module Dry
  module Schema
    # Message objects used by message sets
    #
    # @api public
    class Message
      module Or
        # @api private
        def self.[](left, right, messages)
          msgs = [left, right].flatten
          paths = msgs.map(&:path)

          if paths.uniq.size == 1
            SinglePath.new(left, right, messages)
          elsif MultiPath.handler(right)
            if MultiPath.handler(left) && paths.uniq.size > 1
              MultiPath.new(left, right)
            else
              right
            end
          else
            msgs.max
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dry-schema-1.10.6 lib/dry/schema/message/or.rb
dry-schema-1.10.5 lib/dry/schema/message/or.rb
dry-schema-1.10.4 lib/dry/schema/message/or.rb
dry-schema-1.10.3 lib/dry/schema/message/or.rb
dry-schema-1.10.2 lib/dry/schema/message/or.rb
dry-schema-1.10.1 lib/dry/schema/message/or.rb
dry-schema-1.9.3 lib/dry/schema/message/or.rb