Sha256: 211d4bb69c6fbf6f3dbfcf7944eae823a36ad1c96f69c3c62ae32c552865c22e
Contents?: true
Size: 1.41 KB
Versions: 7
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true require "dry/schema/message/or/abstract" module Dry module Schema class Message module Or # A message type used by OR operations with the same path # # @api public class SinglePath < Abstract # @api private attr_reader :path # @api private attr_reader :_path # @api private attr_reader :messages # @api private def initialize(*args, messages) super(*args) @messages = messages @path = left.path @_path = left._path end # Dump a message into a string # # Both sides of the message will be joined using translated # value under `dry_schema.or` message key # # @see Message#dump # # @return [String] # # @api public def dump @dump ||= "#{left.dump} #{messages[:or][:text]} #{right.dump}" end alias_method :to_s, :dump # Dump an `or` message into a hash # # @see Message#to_h # # @return [String] # # @api public def to_h @to_h ||= _path.to_h(dump) end # @api private def to_a @to_a ||= [left, right] end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems