Sha256: 2e34ec9de9f2def9de6f91abfe49d22c1c2b4abcba2d2583052096a5d48a5564
Contents?: true
Size: 869 Bytes
Versions: 3
Compression:
Stored size: 869 Bytes
Contents
# encoding: utf-8 if defined?('ActiveRecord') module Rubymisc module ArValidates def validates_url(attribute = :url) validates_presence_of attribute validates_length_of attribute, :minimum => 12 validates_format_of attribute, :with => Regex.url, :message => %/isn't a valid URL./ end def validates_email(attribute = :email) validates_presence_of attribute validates_length_of attribute, :minimum => 5 validates_format_of attribute, :with => Regex.email, :message => %/isn't a valid email./ end def validates_image_url(attribute = :image_url) validates attribute, allow_blank: true, format: { with: %r{\.(gif|jpg|png)$}i, message: 'must be a URL for GIF, JPG or PNG image.' } end end ActiveRecord::Base.extend ArValidates end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubymisc-0.0.3 | lib/rubymisc/ext/active_record.rb |
rubymisc-0.0.2 | lib/rubymisc/ext/active_record.rb |
rubymisc-0.0.1 | lib/rubymisc/ext/active_record.rb |