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-0.9.7 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.9.6 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.9.5 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.9.4 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.9.3 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.9.2 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.8 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.7 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.6 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.5 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.4 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.3 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.2 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.1 lib/polyblock/validators/polyblock_presence_validator.rb
polyblock-0.8.0 lib/polyblock/validators/polyblock_presence_validator.rb