Sha256: 49d155d226f84593738a5e2632b56dda51619ab332f12744f9b33b7159cf8231

Contents?: true

Size: 1.35 KB

Versions: 13

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require "pathname"
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

13 entries across 13 versions & 1 rubygems

Version Path
dry-validation-1.10.0 lib/dry/validation/constants.rb
dry-validation-1.9.0 lib/dry/validation/constants.rb
dry-validation-1.8.1 lib/dry/validation/constants.rb
dry-validation-1.8.0 lib/dry/validation/constants.rb
dry-validation-1.7.0 lib/dry/validation/constants.rb
dry-validation-1.6.0 lib/dry/validation/constants.rb
dry-validation-1.5.6 lib/dry/validation/constants.rb
dry-validation-1.5.5 lib/dry/validation/constants.rb
dry-validation-1.5.4 lib/dry/validation/constants.rb
dry-validation-1.5.3 lib/dry/validation/constants.rb
dry-validation-1.5.2 lib/dry/validation/constants.rb
dry-validation-1.5.1 lib/dry/validation/constants.rb
dry-validation-1.5.0 lib/dry/validation/constants.rb