Sha256: 0625e81107ac05345cea5a4421ea9ee5c37b28f896103ede40d4649736247f4d

Contents?: true

Size: 1004 Bytes

Versions: 11

Compression:

Stored size: 1004 Bytes

Contents

# frozen_string_literal: true

require 'pathname'
require 'dry/core/constants'

module Dry
  # Common constants used across the library
  #
  # @api public
  module Schema
    include Core::Constants

    LIST_SEPARATOR = ', '
    QUESTION_MARK = '?'
    DOT = '.'

    # Path to the default set of localized messages bundled within the gem
    DEFAULT_MESSAGES_PATH = Pathname(__dir__).join('../../../config/errors.yml').realpath.freeze

    # Default namespace used for localized messages in YAML files
    DEFAULT_MESSAGES_ROOT = 'dry_schema'

    # An error raised when DSL is used in an incorrect way
    InvalidSchemaError = Class.new(StandardError)

    # An error raised when a localized message cannot be found
    MissingMessageError = Class.new(StandardError) do
      # @api private
      def initialize(path)
        *rest, rule = path
        super(<<~STR)
          Message template for #{rule.inspect} under #{rest.join(DOT).inspect} was not found
        STR
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dry-schema-1.3.4 lib/dry/schema/constants.rb
dry-schema-1.3.3 lib/dry/schema/constants.rb
dry-schema-1.3.2 lib/dry/schema/constants.rb
dry-schema-1.3.1 lib/dry/schema/constants.rb
dry-schema-1.3.0 lib/dry/schema/constants.rb
dry-schema-1.2.0 lib/dry/schema/constants.rb
dry-schema-1.1.0 lib/dry/schema/constants.rb
dry-schema-1.0.3 lib/dry/schema/constants.rb
dry-schema-1.0.2 lib/dry/schema/constants.rb
dry-schema-1.0.1 lib/dry/schema/constants.rb
dry-schema-1.0.0 lib/dry/schema/constants.rb