Socket
Socket
Sign inDemoInstall

postal-address-field-names

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postal-address-field-names

Internationalisation library for postal address field names, using the Oasis XAL standard


Version published
Weekly downloads
233
increased by37.87%
Maintainers
1
Install size
44.0 kB
Created
Weekly downloads
 

Readme

Source

postal-address-field-names

Built with
typescript version dependants license

This module exports address field names for every country, in English. This is useful as many countries have subtle differences in field names (e.g. Postcode in the UK vs ZIP code in the US). It is based on the Oasis XAL standard for addresses.

The output is c.33kb (minified) with no dependencies, and it will work on both node & the browser. It also includes Typescript types for your convenience.

Sample

[
  //...
  {
    name: "United Kingdom",
    iso: "GB",
    fields: {
      addressLine1: "Address 1",
      addressLine2: "Address 2",
      locality: "Town/city",
      administrativeArea: "County",
      postalCode: "Postcode",
    },
  },
  {
    name: "United States",
    iso: "US",
    fields: {
      addressLine1: "Address 1",
      addressLine2: "Address 2",
      locality: "City",
      administrativeArea: "State",
      postalCode: "ZIP code",
    },
  },
  //...
];

Note that several fields are excluded from this array to save space, as they exist (and are named the same) for all countries. These are:

  • givenName
  • additionalNames
  • familyName
  • organisation
  • sortingCode - Rarely used so this is omitted, but some regions use sorting code as well as postal code (often users will place this in address line 2 instead).
  • country

Use

Get field names for a specific country

import countryAddressDetails, {
  CountryCodes,
} from "postal-address-field-names";

function getFieldNames(countryISO: CountryCodes) {
  const countryISO = "GB";
  const country = countryAddressDetails.find(
    (country) => country.iso === countryISO
  );
  return country.fields;
}

Typescript Helpers

The module includes a few useful Typescript helpers:

  • CountryCodes - ENUM with each 2-letter country code in capital letters
  • AddressFields - Full OASIS XAL address field names interface
  • CountryAddressDetails - The type exported by this module (as Array<CountryAddressDetails>)

Built by Skyhook

This module is contributed by the team at Skyhook

FAQs

Last updated on 08 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc