Skip to the content

address-plusアドレスプラス

Parse, validate, format and compare addresses locally, add country modules and mount an optional native form field.

address-plus extends the parse-address style with typed results, validation, formatting and country modules. About the name

Contents

Reference · Australian country module

CountryValidationtype

What a country module's validator returns: the errors and the warnings it found.

Import it

import type { CountryValidation } from "@johnmorrisdotca/address-plus/au";

Also exported from: @johnmorrisdotca/address-plus/gb, @johnmorrisdotca/address-plus/de, @johnmorrisdotca/address-plus/fr, @johnmorrisdotca/address-plus

Definition

interface CountryValidation {
    errors: ValidationError[];
    warnings: ValidationError[];
}

Members

NameTypeDescription
errorsValidationError[]
warningsValidationError[]

Examples

import { parseAustralianAddress, validateAustralianAddress } from "@johnmorrisdotca/address-plus/au";
import type { CountryValidation } from "@johnmorrisdotca/address-plus/au";

const parsedAddress1=parseAustralianAddress("1 Main St, Sydney VIC 2000");
if (!parsedAddress1) throw new Error("The example address did not parse.");
console.log(validateAustralianAddress(parsedAddress1).warnings.map((one) => one.code));
// → ["POSTAL_REGION_MISMATCH"]
[ 'POSTAL_REGION_MISMATCH' ]

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/address-plus 1.7.0.