Sha256: 9e11dc5261198ec3495dbfedaad5e469085779c69fbfa3ebc182d3fa67fea4c7
Contents?: true
Size: 747 Bytes
Versions: 3
Compression:
Stored size: 747 Bytes
Contents
module ActiveModel module Validations class UrlValidator < EachValidator def validate_each(record, attribute, value) if value.to_s !~ Validators::URL_FORMAT record.errors.add( attribute, :invalid_url, :message => options[:message], :value => value ) end end end module ClassMethods # Validates weather or not the specified URL is valid. # # class User < ActiveRecord::Base # validates_url_format_of :site # end # def validates_url_format_of(*attr_names) validates_with UrlValidator, _merge_attributes(attr_names) end alias_method :validates_url, :validates_url_format_of end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
validators-0.1.3 | lib/validators/validates_url_format_of.rb |
validators-0.1.2 | lib/validators/validates_url_format_of.rb |
validators-0.1.1 | lib/validators/validates_url_format_of.rb |