resolver
import { resolveThaiAddress } from 'thaizip'
resolveThaiAddress
Section titled “resolveThaiAddress”function resolveThaiAddress(record: ThaiAddressRecord): ResolvedThaiAddressConverts a ThaiAddressRecord into a ResolvedThaiAddress — a full address object carrying two sets of field names at once: the Thai convention (tambon/amphure/province) and the English convention (subdistrict/district/postalCode) — same values either way. Pick whichever you prefer when saving to a database.
Parameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
record | ThaiAddressRecord | — (required) | The record to convert (e.g. a searchThaiAddress result, or the value a user picked from a dropdown) |
Returns
Section titled “Returns”type ResolvedThaiAddress = { tambon: string tambonEn: string amphure: string amphureEn: string province: string provinceEn: string zipCode: string subdistrict: string subdistrictEn: string district: string districtEn: string postalCode: string}- No text transformation happens here — it’s a direct copy of
record’s fields into both naming schemes - Values that are duplicated in pairs:
tambon=subdistrict,tambonEn=subdistrictEn,amphure=district,amphureEn=districtEn,zipCode=postalCode - Province is shared between both conventions —
province/provinceEnare the same names in either scheme (there’s no separatestate-style alias) - Used internally by
selectSuggestiononuseThaiAddressAutocompleteto return the resolved address to the caller
Example
Section titled “Example”import { resolveThaiAddress, searchThaiAddress } from 'thaizip'
const [record] = searchThaiAddress(index, 'ลาดพร้าว')const address = resolveThaiAddress(record)
// Thai conventionaddress.tambon // 'ลาดพร้าว'address.amphureaddress.provinceaddress.zipCode
// English convention — same valuesaddress.subdistrict // === address.tambonaddress.district // === address.amphureaddress.postalCode // === address.zipCode