Field
interface Field {
label_id: string;
label: string;
label_optional: string;
required: boolean;
autocomplete: 'country' | 'email' | 'given-name' | 'family-name' | 'tel' | 'address-line1' | 'address-line2' | 'address-line3' | 'address-level4' | 'address-level3' | 'address-level2' | 'address-level1' | 'postal-code';
input: FieldInput;
format?: FieldFormat;
errors: Partial<Record<FieldError, string>>;
}A field as a client reads it.
Properties
label_id: string
Where the field's texts are in /v1/locales/:lang: fields.postcode.zip_code holds label, label_optional and errors.* for a US postcode. A page overrides one of them by this key plus the text's own, fields.postcode.zip_code.errors.invalid.
label: string
The label to show when the field is required.
label_optional: string
The label to show when it is not: the label with the language's "optional" note.
required: boolean
Whether an empty value is refused. Decides between label and label_optional.
autocomplete: 'country' | 'email' | 'given-name' | 'family-name' | 'tel' | 'address-line1' | 'address-line2' | 'address-line3' | 'address-level4' | 'address-level3' | 'address-level2' | 'address-level1' | 'postal-code'
What the field is, as an HTML autocomplete token: put it on the control, and browser autofill fills the right value. It says what a field holds whatever its name.
input: FieldInput
How the control is drawn.
format: FieldFormat
How the value is checked and written: on postcode and phone_number only.
errors: Partial<Record<FieldError, string>>
What the form shows under the field when a value is refused, keyed by what is wrong (FieldError). Only the errors this field can raise, as whole sentences in lang, with the example and the length limit already filled in.