Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 1x 1x 1x 1x | import { type AnyFieldApi } from '@tanstack/react-form';
export const getHintMessage = (field: AnyFieldApi) => {
const {
meta: { errors, isTouched, isDirty },
} = field.state;
const { submissionAttempts } = field.form.state;
const showError = isTouched || isDirty || submissionAttempts > 0;
const firstError = errors[0] as { message?: string } | undefined;
return showError ? firstError?.message : undefined;
};
export const normalizePath = (raw: string | null) => {
const value = (raw ?? '').trim();
if (!value) return '/';
if (value.startsWith('//') || value.includes('://')) return '/';
return value.startsWith('/') ? value : `/${value}`;
};
|