Sha256: 6b0a865759ab12674ae06f10669e1936e739594cfd0761ff9fdb842d30bdaf30
Contents?: true
Size: 773 Bytes
Versions: 1
Compression:
Stored size: 773 Bytes
Contents
require 'active_support/core_ext/hash/reverse_merge' require 'active_model/validations' module ValidatesFormattingOf module Validations class Validator < ActiveModel::Validations::FormatValidator def initialize(options = {}, format = nil) return if format.blank? validation = Method.find(nil, :using => format) options.reverse_merge!(:with => validation.regex, :message => validation.message) super options end end Method.validations.each do |key, value| class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 class #{key.to_s.camelize}Validator < Validator def initialize(options = {}) super options, #{key.to_sym.inspect} end end RUBY_EVAL end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_formatting_of-0.8.0 | lib/validates_formatting_of/validator.rb |