From 5e57fdfd11d16cf599d67f2ebc5af60829f26fd4 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 1 May 2026 23:12:43 +0300 Subject: [PATCH] fix(tochka): allow saving credential with empty customerCode/accountCode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User flow: paste JWT -> save -> «Проверить» fetches customers list -> fill customerCode/accountId from that list. Required min(1) blocked this. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/api/src/modules/tochka/routes.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/src/modules/tochka/routes.ts b/apps/api/src/modules/tochka/routes.ts index ea1760e..64d2610 100644 --- a/apps/api/src/modules/tochka/routes.ts +++ b/apps/api/src/modules/tochka/routes.ts @@ -10,7 +10,9 @@ const ENV = ['sandbox', 'prod'] as const; const CredentialUpsert = z.object({ environment: z.enum(ENV), jwt: z.string().min(5), - customerCode: z.string().min(1).max(100), + // customerCode/accountCode можно оставить пустыми и заполнить после «Проверить»: + // тестовый запрос к /open-banking/v1.0/customers вернёт реальные коды. + customerCode: z.preprocess((v) => (typeof v === 'string' ? v.trim() : v), z.string().max(100).default('')), accountCode: optionalText(100), bankAccountId: z.string().uuid().nullable(), });