Sha256: bd3177855cc7404427540e1f182d588913dc5edc9ca289e6dfb5f5e1931deffe

Contents?: true

Size: 298 Bytes

Versions: 1

Compression:

Stored size: 298 Bytes

Contents

module Citizenship
  def self.valid_zip_code!(zip_code)
    regexp = /^(\d{4})-(\d{3})$/
    raise ZipCodeError, :invalid_zip_code unless zip_code.match(regexp)
    zip_code
  end

  def self.valid_zip_code?(zip_code)
    valid_zip_code!(zip_code)
    true
  rescue ZipCodeError
    false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
citizenship-1.0.0 lib/citizenship/zip_code.rb