Skip to main content

Module lead

Module lead 

Source
Expand description

The contact form’s rules: what a valid email and phone are, the request the form sends, and what the worker’s answer means.

The worker behind ENDPOINT applies the same rules (services/leads/src/lead.js), and both walk one set of vectors (crates/logicaffeine_tests/tests/fixtures/lead_vectors.json), so the page never refuses what the worker would take, or sends what it would refuse.

Structs§

FieldErrors
What is wrong with each field; nothing when both are fine.
Phone
A phone as the worker stores it: the trimmed number as typed, and its digits alone.

Enums§

EmailError
Outcome
What the worker’s answer means for the form.
PhoneError

Constants§

ENDPOINT
Where the form sends its request.
SOURCE
The form’s tag in every request, so the team can tell where a request came from. The page’s tag on the wire. It keeps its old name: the lead worker is deployed on it, and a lead from the contact page is the same lead.
TURNSTILE_ACTION
The action the form’s Turnstile widget stamps on its token; the worker’s siteverify check refuses a token that carries any other.

Functions§

request_body
The JSON the worker reads, { email, phone, turnstile_token, source, website }, or what is wrong with the fields. The honeypot (website) rides untouched: the worker decides what a filled one means.
trim_field
value without leading or trailing Unicode white space or byte-order marks. str::trim keeps U+FEFF, which a paste from some apps carries, so it is not the rule.
validate_email
A valid email: the trimmed local part as typed, @, the domain lower-cased.
validate_phone
A phone is optional: nothing, or only white space, is no phone.