Reference · Parsing, formatting and shared types
getValidationErrorsfunction
The errors validateAddress finds, without the rest of its result.
Import it
import { getValidationErrors } from "@johnmorrisdotca/address-plus";
Definition
function getValidationErrors(addressString: string, options?: ValidationOptions): ValidationError[]
Parameters
| Name | Type | Description |
|---|---|---|
addressString | string | The address as one string. |
options (optional) | ValidationOptions | What to require and how strict to be (see |
Returns
ValidationError[]
The errors, each with its field, code and message; an empty array when there are none.
Examples
import { getValidationErrors } from "@johnmorrisdotca/address-plus";
console.log(getValidationErrors("123 Main St, Seattle, NY 98101", { strictPostalValidation: true }).map((error) => error.code));
// → ["POSTAL_REGION_MISMATCH"][ 'POSTAL_REGION_MISMATCH' ]What it prints (run when this page was built)