Sha256: b332fc0dc4f23144bbaed1a38cc27705113108b7e9cbc128beecd29e83efd586
Contents?: true
Size: 596 Bytes
Versions: 7
Compression:
Stored size: 596 Bytes
Contents
# frozen_string_literal: true module Atacama # A description of the signature of the parameter being validated class Parameter attr_reader :name, :type def initialize(name:, type: nil) @name = name @type = type end # Determine the validity of a value for an optionally given type. Raises a # type error on failure. # @raise [Atacama::TypeError] # @returns Boolean def valid?(value) return true if type.nil? type[value] true rescue Dry::Types::ConstraintError => error raise TypeError, error.message end end end
Version data entries
7 entries across 7 versions & 1 rubygems