Reference · Parsing, formatting and shared types
isValidAddressfunction
Whether an address passes validateAddress.
Import it
import { isValidAddress } from "@johnmorrisdotca/address-plus";
Definition
function isValidAddress(addressString: string, options?: ValidationOptions): boolean
Parameters
| Name | Type | Description |
|---|---|---|
addressString | string | The address as one string. |
options (optional) | ValidationOptions | What to require and how strict to be (see |
Returns
boolean
true when it has no errors, false otherwise. Warnings do not make it invalid unless
strictPostalValidation turns them into errors.
Examples
import { isValidAddress } from "@johnmorrisdotca/address-plus";
console.log(isValidAddress("123 Main St, Seattle, NY 98101", { strictPostalValidation: true }));
// → falsefalseWhat it prints (run when this page was built)