feat(inbounds): clearer client validation errors on save

When an inbound save fails Zod validation, the toast previously showed a
raw path like `settings.clients.494.tgId: Invalid input`, which gave no
hint which of hundreds of clients was at fault. Resolve the client array
index back to the client email, name the field, and append a "(+N more)"
count when several fields fail. console.error now logs a readable list of
every issue instead of dumping the whole form.

Adds the invalidClientField/invalidField/moreIssues toast strings across
all 13 translations.
This commit is contained in:
MHSanaei
2026-05-31 22:41:58 +02:00
parent 61e8bed3e0
commit 76dbbfc1f8
16 changed files with 167 additions and 25 deletions
@@ -48,6 +48,7 @@ import { FinalMaskForm } from '@/lib/xray/forms/transport';
import './InboundFormModal.css';
import { AdvancedAllEditor, AdvancedSliceEditor } from './advanced-editors';
import { formatInboundIssue, formatInboundValidation } from './formatValidationError';
import {
HttpFields,
HysteriaFields,
@@ -360,18 +361,12 @@ export default function InboundFormModal({
const values = form.getFieldsValue(true) as InboundFormValues;
const parsed = InboundFormSchema.safeParse(values);
if (!parsed.success) {
const issue = parsed.error.issues[0];
const path = Array.isArray(issue?.path) && issue.path.length > 0
? issue.path.join('.')
: '';
const baseMsg = issue?.message ?? 'somethingWentWrong';
const display = path ? `${path}: ${baseMsg}` : baseMsg;
messageApi.error(t(baseMsg, { defaultValue: display }));
console.error('[InboundFormModal] schema validation failed', {
path: issue?.path,
message: issue?.message,
values,
});
const issues = parsed.error.issues;
messageApi.error(formatInboundValidation(issues, values, t));
console.error(
'[InboundFormModal] schema validation failed:',
issues.map((issue) => formatInboundIssue(issue, values, t)),
);
return;
}
setSaving(true);