Sha256: 17e68a4a6ecd017dfef98fa438017fabb3df394f5a9c4ffb9fbca8586b30e10c

Contents?: true

Size: 379 Bytes

Versions: 33

Compression:

Stored size: 379 Bytes

Contents

# frozen_string_literal: true

module EacRailsUtils
  # https://stackoverflow.com/questions/10070786/rails-3-validation-presence-false
  class NoPresenceValidator < ActiveModel::EachValidator
    def validate_each(record, attribute, _value)
      return if record.send(attribute).blank?

      record.errors[attribute] << (options[:message] || 'must be blank')
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
eac_rails_utils-0.22.2 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.22.1 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.22.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.21.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.20.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.19.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.18.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.17.2 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.17.1 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.17.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.16.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.15.2 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.15.1 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.15.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.14.1 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.14.0 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.13.5 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.13.4 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.13.3 app/validators/eac_rails_utils/no_presence_validator.rb
eac_rails_utils-0.13.2 app/validators/eac_rails_utils/no_presence_validator.rb