Sha256: 8907a49f1d256d2edb7ab535c827b662b77c19be5e3ac938fe5c26264ff0cf9e

Contents?: true

Size: 455 Bytes

Versions: 7

Compression:

Stored size: 455 Bytes

Contents

# frozen_string_literal: true

module Strict
  module Validators
    class AnyOf
      attr_reader :subvalidators

      def initialize(*subvalidators)
        @subvalidators = subvalidators
      end

      def ===(value)
        subvalidators.any? do |subvalidator|
          subvalidator === value
        end
      end

      def inspect
        "AnyOf(#{subvalidators.map(&:inspect).join(', ')})"
      end
      alias to_s inspect
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
strict-1.5.0 lib/strict/validators/any_of.rb
strict-1.4.0 lib/strict/validators/any_of.rb
strict-1.3.1 lib/strict/validators/any_of.rb
strict-1.3.0 lib/strict/validators/any_of.rb
strict-1.2.0 lib/strict/validators/any_of.rb
strict-1.1.0 lib/strict/validators/any_of.rb
strict-1.0.0 lib/strict/validators/any_of.rb