class Dry::Validation::Message

Message message

@api public

Attributes

meta[R]

Optional hash with meta-data

@return [Hash]

@api public

path[R]

The path to the value with the error

@return [Array<Symbol, Integer>]

@api public

text[R]

The error message text

@return [String] text

@api public

Public Class Methods

[](text, path, meta) click to toggle source

Build an error

@return [Message, Message::Localized]

@api private

# File lib/dry/validation/message.rb, line 65
def self.[](text, path, meta)
  klass = text.respond_to?(:call) ? Localized : Message
  klass.new(text, path: path, meta: meta)
end
new(text, path:, meta: EMPTY_HASH) click to toggle source

Initialize a new error object

@api private rubocop: disable Lint/MissingSuper

# File lib/dry/validation/message.rb, line 74
def initialize(text, path:, meta: EMPTY_HASH)
  @text = text
  @path = Array(path)
  @meta = meta
end

Public Instance Methods

base?() click to toggle source

Check if this is a base error not associated with any key

@return [Boolean]

@api public

# File lib/dry/validation/message.rb, line 86
def base?
  @base ||= path.compact.empty?
end
to_s() click to toggle source

Dump error to a string

@return [String]

@api public

# File lib/dry/validation/message.rb, line 95
def to_s
  text
end