Sha256: 241ffac1c35db6e853171de4d640fa14ff7760be5b60ba3e6def3e19911ce1d2

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

class MiniDefender::Rule
  def self.signature
    raise NotImplementedError, 'Use a concrete implementation.'
  end

  # @param [Array] args Set of positional arguments
  # @return [MiniDefender::Rule]
  def self.make(args)
    self.new
  end

  # @return [Boolean]
  def self.available?
    true
  end

  # @param [MiniDefender::Validator] validator
  # @return [Boolean]
  def implicit?(validator)
    false
  end

  # @param [MiniDefender::Validator] validator
  # @return [Boolean]
  def defaults?(validator)
    false
  end

  # @param [MiniDefender::Validator] validator
  # @return [?Object]
  def default_value(validator)
    nil
  end

  # Instruct the validator to stop validation for the current attribute
  # when the first error is encountered
  def bails?
    false
  end

  # Instructs the validator to stop validation for all rules for the current attribute
  def stops?
    false
  end

  # @param [MiniDefender::Validator] validator
  # @return [Boolean]
  def active?(validator)
    true
  end

  # @param [MiniDefender::Validator]
  # @return [Boolean]
  def excluded?(validator)
    false
  end

  def coerce(value)
    value
  end

  # @param [Object] attribute
  # @param [Object] value
  # @param [MiniDefender::Validator] validator
  def passes?(attribute, value, validator)
    raise NotImplementedError, 'Use a concrete implementation.'
  end

  # @param [Object] attribute
  # @param [Object] value
  # @param [MiniDefender::Validator] validator
  def message(attribute, value, validator)
    raise NotImplementedError, 'Use a concrete implementation.'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mini_defender-0.1.4 lib/mini_defender/rule.rb
mini_defender-0.1.3 lib/mini_defender/rule.rb
mini_defender-0.1.2 lib/mini_defender/rule.rb
mini_defender-0.1.1 lib/mini_defender/rule.rb
mini_defender-0.1.0 lib/mini_defender/rule.rb