File: validates_format_of.rb

package info (click to toggle)
ruby-validatable 1.6.7-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 284 kB
  • sloc: ruby: 1,636; makefile: 10
file content (13 lines) | stat: -rw-r--r-- 274 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
module Validatable
  class ValidatesFormatOf < ValidationBase #:nodoc:
    required_option :with
  
    def valid?(instance)
      not (instance.send(self.attribute).to_s =~ self.with).nil?
    end
    
    def message(instance)
      super || "is invalid"
    end
  end
end