mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-13 10:34:19 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user