module ActiveValidators
Public Class Methods
activate(:phone, :email, :date)
click to toggle source
activate(:all)
Require each validator independently or just pass :all
# File lib/activevalidators.rb, line 14 def self.activate(*validators) syms = validators.include?(:all) ? activevalidators : validators.map(&:to_s) & activevalidators syms.each do |validator_name| require "active_validators/active_model/validations/#{validator_name}_validator" end end
activevalidators()
click to toggle source
# File lib/activevalidators.rb, line 5 def self.activevalidators %w(email url respond_to phone slug ip credit_card date password twitter postal_code tracking_number siren ssn sin nino barcode date hex_color regexp) end
Public Instance Methods
define_helper_method_for_validator(validator)
click to toggle source
Defines methods like validates_credit_card
# File lib/activevalidators.rb, line 23 def define_helper_method_for_validator(validator) define_method('validates_'+validator) do |*fields| options ||= (fields.delete fields.find { |f| f.kind_of? Hash}) || true args = fields.push({ validator => options }) validates(*args) end end