export const signupFormStepUsernameSchema = z.object({ username: z .string() .trim() .superRefine((val, ctx) => { const minChars = 4 const maxChars = 20 // ... other validation if (val.length < minChars) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `errors.invalid.username.minLength|{"min": ${minChars}}`, }) return z.NEVER } if (val.length > maxChars) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `errors.invalid.username.maxLength|{"max": ${maxChars}}`, }) return z.NEVER } // ... other validation }), }).strict().required();ctx.addIssue({ code: z.ZodIssueCode.custom, message: `errors.invalid.username.maxLength|{"max": ${maxChars}}` });const dirtyErrorKeyAndTranslationValues = errors.username ? (errors.username.message as string).split("|"): "|".split("|");let refinedErrorKey = ""; if ( (dirtyErrorKeyAndTranslationValues[0] as string) && (dirtyErrorKeyAndTranslationValues[0] as string).length > 0 ) { refinedErrorKey = dirtyErrorKeyAndTranslationValues[0]; }let refinedTranslationValues = {} as TranslationValues; if ( (dirtyErrorKeyAndTranslationValues[1] as string) && (dirtyErrorKeyAndTranslationValues[1] as string).length > 0 ) { refinedTranslationValues = JSON.parse( dirtyErrorKeyAndTranslationValues[1] ) as TranslationValues; }<p> {errors.username ? t( refinedErrorKey, Object.keys(refinedTranslationValues).length === 0 ? refinedTranslationValues : undefined ) : " "} </p>