Sha256: 737f3345a40e1384d159faa2e0bde6a4a61e7c26431e9cbbc0bfc497be413d03

Contents?: true

Size: 632 Bytes

Versions: 35

Compression:

Stored size: 632 Bytes

Contents

require 'active_model/validations/presence'

module Polyblock
  module Validators
    class PolyblockPresenceValidator < ActiveModel::EachValidator

      def validate_each(record, attribute, value)
        unless record.send(attribute).present?
          record.errors.add(attribute, :blank, options)
        end
      end

      def self.helper_method_name
        :validates_polyblock_presence
      end

    end

    module HelperMethods
      def validates_polyblock_presence(*attr_names)
        options = _merge_attributes(attr_names)
        validates_with PolyblockPresenceValidator, options.dup
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
polyblock-1.2.6 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.2.5 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.2.4 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.2.3 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.2.2 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.2.1 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.2.0 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.1.1 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.1.0 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.8 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.7 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.6 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.5 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.4 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.3 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.2 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.1 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-1.0.0 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.9.9 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.9.8 lib/polyblock/validators/polyblock_presence_validator.rb