Sha256: 522c9c3fc3a634f4d28c4f20ec65802709866c08a3bc2ddd45291fb12b595258
Contents?: true
Size: 850 Bytes
Versions: 1
Compression:
Stored size: 850 Bytes
Contents
module ValidatesFormattingOf module ValidationAddition attr_reader :validations def add(name, regex, message = nil) @validations ||= {} @validations[name.to_sym] = Validation.new(name.to_sym, regex, message) end def find(attribute, opts = {}) method = opts[:using].nil? ? attribute : opts[:using] if !exists? method raise MissingValidation, "The validation method #{method.to_sym.inspect} has not been defined." end if method.to_sym == :ip_address warn "[DEPRECATION] The :ip_address validation for `validates_formatting_of` is DEPRECATED. Please update your model validations to use :ip_address_v4. This method will be removed by version 0.7.0." end @validations[method.to_sym] end def exists?(name) !@validations[name.to_sym].nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_formatting_of-0.6.9 | lib/validates_formatting_of/validation_addition.rb |