Sha256: 852b8a8f0d8918293c38e86784fc3bbdc91f2c7828c7c1cdb7d05b0a7a945789

Contents?: true

Size: 494 Bytes

Versions: 4

Compression:

Stored size: 494 Bytes

Contents

module Validators

  # Checks that an attribute is absent. The opposite of Rails's PresenceValidator
  class AbsenceValidator < ActiveModel::EachValidator

    # This is a Rails method for custom Validators. Please read {http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates_each the Rails docs} for more info
    def validate_each(record, attribute, value)
      record.errors.add(attribute, :invalid, options) unless value.blank?
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blogit-1.1.2 lib/validators/absence_validator.rb
blogit-1.1.1 lib/validators/absence_validator.rb
blogit-1.1.0 lib/validators/absence_validator.rb
blogit-1.0.0 lib/validators/absence_validator.rb