Sha256: 2b699db863e62062d026bea8b0b0b601235fe9d619cf94c7a4ccee6a2715a653

Contents?: true

Size: 597 Bytes

Versions: 8

Compression:

Stored size: 597 Bytes

Contents

module Heimdallr
  # This is an internal class which runs security validations when {Proxy::Record#save}
  # and {Proxy::Record#save!} are invoked. +ActiveRecord::Base#save+ (and +save!+) clears
  # the +errors+ object internally, so this hack is required to avoid monkey-patching it.
  class Validator < ActiveModel::Validator
    # Run the +record.heimdallr_validators+ on the current record, if any.
    def validate(record)
      if record.heimdallr_validators
        record.heimdallr_validators.each do |validator|
          validator.validate(record)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
heimdallr-1.0.6 lib/heimdallr/validator.rb
heimdallr-1.0.4 lib/heimdallr/validator.rb
heimdallr-1.0.3 lib/heimdallr/validator.rb
heimdallr-1.0.2 lib/heimdallr/validator.rb
heimdallr-1.0.1 lib/heimdallr/validator.rb
heimdallr-1.0.0 lib/heimdallr/validator.rb
heimdallr-1.0.0.RC2 lib/heimdallr/validator.rb
heimdallr-0.0.2 lib/heimdallr/validator.rb