Sha256: 872fc99f08a45c2f2e7542942c4893fe6390f01b38f6c7435de4ea9f7df4642e

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require 'dry/core/constants'

module Dry
  module Validation
    include Dry::Core::Constants

    DOT = '.'

    # Root path is used for base errors in hash representation of error messages
    ROOT_PATH = [nil].freeze

    # Path to the default errors locale file
    DEFAULT_ERRORS_NAMESPACE = 'dry_validation'

    # Path to the default errors locale file
    DEFAULT_ERRORS_PATH = Pathname(__FILE__).join('../../../../config/errors.yml').realpath.freeze

    # Mapping for block kwarg options used by block_options
    #
    # @see Rule#block_options
    BLOCK_OPTIONS_MAPPINGS = Hash.new { |_, key| key }.update(context: :_context).freeze

    # Error raised when `rule` specifies one or more keys that the schema doesn't specify
    InvalidKeysError = Class.new(StandardError)

    # Error raised when a localized message was not found
    MissingMessageError = Class.new(StandardError)

    # Error raised when trying to define a schema in a contract class that already has a schema
    DuplicateSchemaError = Class.new(StandardError)

    # Error raised during initialization of a contract that has no schema defined
    SchemaMissingError = Class.new(StandardError) do
      # @api private
      def initialize(klass)
        super("#{klass} cannot be instantiated without a schema defined")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-1.2.0 lib/dry/validation/constants.rb
dry-validation-1.1.1 lib/dry/validation/constants.rb