Sha256: 24e5bfecf20d5ffdc28634c47721c5de12fd9fe47fefca4e5fbcb933688461ea

Contents?: true

Size: 574 Bytes

Versions: 6

Compression:

Stored size: 574 Bytes

Contents

module Barometer
  module Query
    module Format
      #
      # eg. H0H 0H0
      #
      class Postalcode < Base
        def self.geo(query); {country_code: 'CA'}; end
        def self.regex
          # Rules: no D, F, I, O, Q, or U anywhere
          # Basic validation: ^[ABCEGHJ-NPRSTVXY]{1}[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}
          #   [ ]?[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[0-9]{1}$
          /^[A-Z]{1}[\d]{1}[A-Z]{1}[ ]?[\d]{1}[A-Z]{1}[\d]{1}$/
        end
      end
    end
  end
end

Barometer::Query::Format.register(:postalcode, Barometer::Query::Format::Postalcode)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
barometer-0.9.7 lib/barometer/query/formats/postalcode.rb
barometer-0.9.6 lib/barometer/query/formats/postalcode.rb
barometer-0.9.5 lib/barometer/query/formats/postalcode.rb
barometer-0.9.4 lib/barometer/query/formats/postalcode.rb
barometer-0.9.3 lib/barometer/query/formats/postalcode.rb
barometer-0.9.2 lib/barometer/query/formats/postalcode.rb