Module: IfdTools::Validations::Phone

Defined in:
lib/ifd_tools/validations/phone.rb

Instance Method Summary collapse

Instance Method Details

#validates_phone(*args) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/ifd_tools/validations/phone.rb', line 5

def validates_phone(*args)
  options = { :format => { :with => /^\(?\d{3}\)?\s*[-|.]?\s*\d{3}\s*[-|.]?\d{4}\s*$/, :message => "'%{value}' is not a valid phone number" } }
  if !args.empty? and args.last.is_a?(Hash)
    options.merge! args.pop
  end
  args.each { |attribute| validates attribute.to_sym, options }
end