Sha256: d0abc80e43dbb09588e9d7de034cc1e4c7145a6bea37ebfd9415553892c8e68d

Contents?: true

Size: 715 Bytes

Versions: 31

Compression:

Stored size: 715 Bytes

Contents

# Validator for {Metasploit::Model::Derivation::ClassMethods#derives}.
class DerivationValidator < ActiveModel::EachValidator
  # Validates that `attribute`'s `value` equals derived_<attribute>'s value.  If they are not equal then the error
  # message is `'must match its derivation'`.
  #
  # @param record [#errors, ActiveRecord::Base] ActiveModel or ActiveRecord
  # @param attribute [Symbol] name of derived attribute.
  # @param value [Object] value of `attribute` in `record`.
  # @return [void]
  def validate_each(record, attribute, value)
    derived_value = record.send("derived_#{attribute}")

    if value != derived_value
      record.errors[attribute] << 'must match its derivation'
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
metasploit-model-0.28.0 app/validators/derivation_validator.rb
metasploit-model-0.28.0-java app/validators/derivation_validator.rb
metasploit-model-0.28.0.pre.engine.pre.requires app/validators/derivation_validator.rb
metasploit-model-0.27.4 app/validators/derivation_validator.rb
metasploit-model-0.27.4-java app/validators/derivation_validator.rb
metasploit-model-0.27.3 app/validators/derivation_validator.rb
metasploit-model-0.27.3-java app/validators/derivation_validator.rb
metasploit-model-0.27.2 app/validators/derivation_validator.rb
metasploit-model-0.27.2-java app/validators/derivation_validator.rb
metasploit-model-0.27.1 app/validators/derivation_validator.rb
metasploit-model-0.27.1-java app/validators/derivation_validator.rb
metasploit-model-0.27.0 app/validators/derivation_validator.rb
metasploit-model-0.27.0-java app/validators/derivation_validator.rb
metasploit-model-0.27.0.pre.dep.pre.railties app/validators/derivation_validator.rb
metasploit-model-0.26.1-java app/validators/derivation_validator.rb
metasploit-model-0.26.1 app/validators/derivation_validator.rb
metasploit-model-0.25.7 app/validators/derivation_validator.rb
metasploit-model-0.25.7-java app/validators/derivation_validator.rb
metasploit-model-0.25.6 app/validators/derivation_validator.rb
metasploit-model-0.25.6-java app/validators/derivation_validator.rb