Sha256: 3adb4070a20de40c8a7d1f341cf4a5da9ae8ef86242f2191dcd5551cc41b4147
Contents?: true
Size: 1.5 KB
Versions: 7
Compression:
Stored size: 1.5 KB
Contents
module Dry module Types extend Dry::Core::ClassAttributes # @!attribute [r] namespace # @return [Container{String => Definition}] 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
7 entries across 7 versions & 1 rubygems