Sha256: ea063f8474946332c9bfb32abf3a255b9bb6d3c38a420c65496bf63cc8e519b1

Contents?: true

Size: 1.26 KB

Versions: 31

Compression:

Stored size: 1.26 KB

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 = "."

    # core processor steps in the default execution order
    STEPS_IN_ORDER = %i[
      key_validator
      key_coercer
      filter_schema
      value_coercer
      rule_applier
    ].freeze

    # 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, paths = [])
        *rest, rule = path
        super(<<~STR)
          Message template for #{rule.inspect} under #{rest.join(DOT).inspect} was not found. Searched in:
          #{paths.map { |string| "\"#{string}\"" }.join("\n")}
        STR
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
dry-schema-1.13.3 lib/dry/schema/constants.rb
dry-schema-1.13.2 lib/dry/schema/constants.rb
dry-schema-1.13.1 lib/dry/schema/constants.rb
dry-schema-1.13.0 lib/dry/schema/constants.rb
dry-schema-1.12.0 lib/dry/schema/constants.rb
dry-schema-1.11.3 lib/dry/schema/constants.rb
dry-schema-1.11.2 lib/dry/schema/constants.rb
dry-schema-1.11.1 lib/dry/schema/constants.rb
dry-schema-1.11.0 lib/dry/schema/constants.rb
dry-schema-1.10.6 lib/dry/schema/constants.rb
dry-schema-1.10.5 lib/dry/schema/constants.rb
dry-schema-1.10.4 lib/dry/schema/constants.rb
dry-schema-1.10.2 lib/dry/schema/constants.rb
dry-schema-1.10.1 lib/dry/schema/constants.rb
dry-schema-1.9.3 lib/dry/schema/constants.rb
dry-schema-1.9.2 lib/dry/schema/constants.rb
dry-schema-1.9.1 lib/dry/schema/constants.rb
dry-schema-1.9.0 lib/dry/schema/constants.rb
dry-schema-1.8.0 lib/dry/schema/constants.rb
dry-schema-1.7.1 lib/dry/schema/constants.rb