ValidateRequest
interface ValidateRequest {
country?: string;
fields: Record<string, string>;
}The body of POST /v1/validate: what a shopper typed into a form for an address in country, keyed by the field names the rules use. Any subset of a form's fields, so a page can check one field as it is typed and every field on submit in one request.
phone_number and postcode are checked. state is not checked itself, but a postcode sent beside it is checked against it, so send the two together. The language of the messages is not in the body: it is ?lang=, as on every route.
Example
CODE
{
"country": "US",
"fields": {
"phone_number": "(415) 555-2671",
"postcode": "10001",
"state": "CA"
}
}Properties
country: string
ISO 3166-1 alpha-2 of the address. Without it, a phone number needs its own +, and a postcode is not checked.
fields: Record<string, string>
Each field's value as typed, keyed by its name in the rules: phone_number, postcode, and state as the code the form submits for it.