Sha256: 06ac23ec836242e943d7e3d3b7ab7143d5b3fc6f5b479ec6f86e57337307262e
Contents?: true
Size: 658 Bytes
Versions: 3
Compression:
Stored size: 658 Bytes
Contents
# frozen_string_literal: true module Attribool::Validators ## # Ensures that a condition is either +nil+ or a +Proc+. class ConditionValidator ## # Construct the validator. # # @param [nil, Proc] condition def initialize(condition) @condition = condition end ## # Is the condition either +nil+ or a +Proc+? # # @return [Boolean] def valid? @condition.nil? || @condition.is_a?(Proc) end ## # The exception to raise if validations fail. # # @return [ArgumentError] the exception with message def error ArgumentError.new("Condition is not a proc") end end end
Version data entries
3 entries across 3 versions & 1 rubygems