feat(languageSchema): split value to extract only language and not country code

pt-BR becomes pt
en-US becomes en
This commit is contained in:
P. Reis 2024-10-07 14:36:26 -03:00
parent f3b7f91a07
commit 0d126ad3b7

View file

@ -42,7 +42,7 @@ const fileSchema = z.custom<File>((value) => value instanceof File);
const percentageSchema = z.coerce.number().int().gte(1).lte(100);
const languageSchema = z.string().transform((val, ctx) => {
val = val.toLowerCase();
val = (val.toLowerCase()).split('-')[0]; // pt-BR -> pt
if (!ISO6391.validate(val)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,