Feat/parse invitation

This commit is contained in:
Kuldeep
2026-10-05 12:59:22 +00:00
parent d907946804
commit 0c95b9b2b1
19 changed files with 1008 additions and 386 deletions
-32
View File
@@ -1,37 +1,5 @@
/* eslint-disable max-classes-per-file */
import type { $ZodIssue } from 'zod/v4/core';
/**
* Formats the Zod validation failures into a single string with one line each: "- <field>: <message>" and top level failures
* with no field path show as "(root)" for better readability.
*
* @param issues The Zod validation failures to format.
* @returns A human readable error string for better debugging.
*/
export const buildErrorDescription = (issues: $ZodIssue[]): string => {
// Initialize an empty array to store the formatted lines.
const lines: string[] = [];
// Iterate over the issues and format them into a string.
for (const issue of issues) {
// Get the issue path.
const issuePath = issue.path.length > 0 ? issue.path.join('.') : '(root)';
// The prefix that Zod adds to messages.
const messagePrefix = 'Invalid input: ';
// Remove the prefix for better readability.
const issueMessage = issue.message.startsWith(messagePrefix) ? issue.message.slice(messagePrefix.length) : issue.message;
// Add the formatted line to the array.
lines.push(`- ${issuePath}: ${issueMessage}`);
}
// Return the formatted string.
return `\n${lines.join('\n')}`;
};
/**
* Thrown when the provided template does not satisfy the XOTemplate schema.
*/