Module: DataMapper::Validate::Format::PhoneNumber
- Defined in:
- lib/dm-validations/formats/phone_number.rb
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/dm-validations/formats/phone_number.rb', line 6 def self.included(base) DataMapper::Validate::FormatValidator::FORMATS.merge!( :phone_number => [ Proc.new { |ph| ph.blank? || ph.gsub(/\D+/, '').length == 10 }, lambda { |field, value| '%s should be 10 digits (include area code)'.t(value) } ] ) end |