Reference · Australian country module
validateAustralianAddressfunction
Checks an Australian address against Australia Post's blocks of postcodes: the postcode is four digits, some state's block holds it, and it is the state named, or one it serves across a border (from the ABS's Postal Areas). Also warns when the state, the postcode or the suburb is missing.
Import it
import { validateAustralianAddress } from "@johnmorrisdotca/address-plus/au";
Definition
function validateAustralianAddress(address: ParsedAddress, options?: ValidationOptions): CountryValidation
Parameters
| Name | Type | Description |
|---|---|---|
address | ParsedAddress | The address as |
options (optional) | ValidationOptions |
|
Returns
CountryValidation
The errors and warnings, each with its field, code and message.
Examples
import { parseAustralianAddress, validateAustralianAddress } 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[0].message);
// → "Postcode 2000 belongs to NSW, not VIC"Postcode 2000 belongs to NSW, not VICWhat it prints (run when this page was built)