Sha256: 01e33278c3eef1deb4772c5aaf7bbea082f85baadaecb4153cf85a0f7a427c3d

Contents?: true

Size: 600 Bytes

Versions: 41

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true

require_relative 'required'

class MiniDefender::Rules::RequiredWithAll < MiniDefender::Rules::Required
  def initialize(targets)
    unless targets.is_a?(Array) && targets.all?{ |t| t.is_a?(String) }
      raise ArgumentError, 'Expected an array of strings.'
    end

    @targets = targets
  end

  def self.signature
    'required_with_all'
  end

  def self.make(args)
    raise ArgumentError, 'Expected at least one argument.' unless args.length >= 1

    self.new(args)
  end

  def implicit?(validator)
    @targets.all? { |t| validator.data.key?(t) }
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
mini_defender-0.6.8 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.6.7 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.6.5 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.6.4 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.6.3 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.6.2 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.6.1 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.6.0 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.8 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.7 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.6 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.5 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.4 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.3 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.2 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.1 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.5.0 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.4.1 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.4.0 lib/mini_defender/rules/required_with_all.rb
mini_defender-0.3.14 lib/mini_defender/rules/required_with_all.rb