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