Sha256: 5149ce4793c855aaf855a7a50960b1824d040fa9039c039fbb71df467b9f7755
Contents?: true
Size: 764 Bytes
Versions: 1
Compression:
Stored size: 764 Bytes
Contents
module ValidatesFormattingOf module ModelAdditions def validates_formatting_of(attribute, opts = {}) # Here is where the input is formatted before it is validated. # Not yet implemented. # # unless opts[:preformat].nil? # before_validation do # # add formatting changes here # end # end regex_for_validation = opts[:regex] || validate_with(opts[:using]) validates_format_of attribute, :with => regex_for_validation, :message => opts[:message] end # Actually retrieve the regex to check against def validate_with(method) formatting.send(method) end # Grab the validating methods def formatting @formatting ||= ValidatingMethods.new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
validates_formatting_of-0.2.0 | lib/validates_formatting_of/model_additions.rb |