Sha256: ee12c4146272cf0466cb68f13403b64f7b3343b83a1c650df4e2ddebd9aec9ef

Contents?: true

Size: 606 Bytes

Versions: 3

Compression:

Stored size: 606 Bytes

Contents

module Protector
  module Adapters
    module ActiveRecord
      module Validations
        def valid?(*args)
          if protector_subject?
            state  = Protector.insecurely{ super(*args) }
            method = new_record? ? :first_uncreatable_field : :first_unupdatable_field
            field  = protector_meta.send(method, protector_changed)

            if field
              errors[:base] << I18n.t('protector.invalid', field: field)
              state = false
            end

            state
          else
            super(*args)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
protector-0.7.7 lib/protector/adapters/active_record/validations.rb
protector-0.7.6 lib/protector/adapters/active_record/validations.rb
protector-0.7.4 lib/protector/adapters/active_record/validations.rb