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