Sha256: 3442535e9f5a24876ed79215608a49a20f1f35f411f51b1da46c85f0d9812cad
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
module Dry module Types extend Dry::Core::ClassAttributes # @!attribute [r] namespace # @return [Container{String => Nominal}] defines :namespace namespace self class SchemaError < TypeError # @param [String,Symbol] key # @param [Object] value # @param [String, #to_s] result def initialize(key, value, result) super("#{value.inspect} (#{value.class}) has invalid type for :#{key} violates constraints (#{result} failed)") end end MapError = Class.new(TypeError) SchemaKeyError = Class.new(KeyError) private_constant(:SchemaKeyError) class MissingKeyError < SchemaKeyError # @param [String,Symbol] key def initialize(key) super(":#{key} is missing in Hash input") end end class UnknownKeysError < SchemaKeyError # @param [<String, Symbol>] keys def initialize(*keys) super("unexpected keys #{keys.inspect} in Hash input") end end class ConstraintError < TypeError # @return [String, #to_s] attr_reader :result # @return [Object] attr_reader :input # @param [String, #to_s] result # @param [Object] input def initialize(result, input) @result = result @input = input if result.is_a?(String) super(result) else super(to_s) end end # @return [String] def to_s "#{input.inspect} violates constraints (#{result} failed)" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-types-0.15.0 | lib/dry/types/errors.rb |