10 lines
413 B
TypeScript
10 lines
413 B
TypeScript
export function validateContact(c: { name: string; email: string | null; telegramChatId: string | null }): string[] {
|
|
const errs: string[] = [];
|
|
if (!c.name?.trim()) errs.push("name");
|
|
const email = c.email?.trim() ?? "";
|
|
const chat = c.telegramChatId?.trim() ?? "";
|
|
if (!email && !chat) errs.push("kanal");
|
|
if (email && !/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) errs.push("email");
|
|
return errs;
|
|
}
|