/** Which pair of fields is compared: it picks the comparison and the message. */ export type FieldMatchKind = 'email' | 'password' | 'phone'; export interface UseFieldMatchOptions { /** The value of the first field. */ value: string; /** The value of the field that repeats it. */ confirmValue: string; /** * `'email'` compares trimmed and without regard to case. `'password'` * and `'phone'` (E.164 values) compare exactly. Each has its own translated message. */ kind: FieldMatchKind; /** * True once the user has tried to submit the form. The message then * shows even if the confirm field was never left. */ submitted?: boolean; /** * Replaces the default preparation of both values before they are * compared, e.g. to strip dots from an address. */ normalise?: (value: string) => string; } export interface UseFieldMatchReturn { /** * True when the two values are equal after normalising. Two empty * fields match: check that they are filled in separately. */ matches: boolean; /** * The translated message, ready for `FormField`'s `error`. Set only * when both fields have text, they differ, and the user has left the * confirm field once or tried to submit. Cleared as soon as they match. * Emptying both fields starts again: the message waits for the confirm * field to be left once more. */ error: string | undefined; /** Spread onto the confirm field's input. */ confirmProps: { onBlur: () => void; }; } /** * "These two fields must match", for email with confirm email and * password with confirm password. It compares the values and says when * to show the message; `FormField` shows and announces it. * * It does not block paste, copy or drop itself. A host that wants the * confirm field typed sets `blockPaste` on that input (any field built * on `TextInput` takes it); password managers still fill both fields. * * @example * const match = useFieldMatch({ * value: email, * confirmValue: emailConfirm, * kind: 'email', * submitted, * }); * * // `disableBuiltInValidation`: the match is this field's only check. * // With EmailInput's own message on too, two messages share one id. * * setEmailConfirm(event.target.value)} * {...match.confirmProps} * /> * */ export declare function useFieldMatch({ value, confirmValue, kind, submitted, normalise, }: UseFieldMatchOptions): UseFieldMatchReturn; //# sourceMappingURL=use-field-match.d.ts.map