function validateAddress
validateAddress(): Promise<AddressValidationResult>

Checks that the parts of an address exist and belong together — a valid province, a district that sits in it, a sub-district that sits in the district, and a postal code that serves that sub-district.

Only the fields you pass are checked, so it works for a partially filled form. The chain stops at the first inconsistent field and names it in errors.

Examples

Example 1

await validateAddress({ province: 'เชียงใหม่', district: 'เมืองเชียงใหม่', subDistrict: 'ศรีภูมิ', postalCode: '50200', }); // { valid: true, errors: {}, match: { ... } }

Example 2

await validateAddress({ province: 'เชียงใหม่', district: 'หาดใหญ่' }); // { valid: false, errors: { district: 'District "หาดใหญ่" is not in province "เชียงใหม่"' } }

Parameters

Return Type

Usage

import { validateAddress } from ".";