Skip to content

Releases: aiji42/zod-i18n

zod-i18n-map-v2.2.0

25 Jan 08:50
89cb63f
Compare
Choose a tag to compare

zod-i18n-map-v2.2.0 (2023-01-25)

Features

zod-i18n-map-v2.1.0

27 Dec 12:19
a487b70
Compare
Choose a tag to compare

zod-i18n-map-v2.1.0 (2022-12-27)

Features

  • add dutch translation file (f4a89e7)

zod-i18n-map-v2.0.0

20 Dec 14:14
e6a3410
Compare
Choose a tag to compare

zod-i18n-map-v2.0.0 (2022-12-20)

Features

i18next.init({
  lng: 'en',
  resources: {
    en: { 
      zod: { // default namespace
        invalid_type: "Error: expected {{expected}}, received {{received}}"
      },
      formValidation: { // custom namespace
        invalid_type: "it is expected to provide {{expected}} but you provided {{received}}"
      },
    },
  },
});

// use default namespace
z.setErrorMap(makeZodI18nMap())
z.string().parse(1) // => Error: expected string, received number

// select custom namespace
z.setErrorMap(makeZodI18nMap({ ns: 'formValidation' }))
z.string().parse(1) // => it is expected to provide string but you provided number
  • handling object schema keys in error messages (f75f458): See here
i18next.init({
  lng: "en",
  resources: {
    en: {
      zod: {
        errors: {
          invalid_type: "Expected {{expected}}, received {{received}}",
          invalid_type_with_path:
            "{{path}} is expected {{expected}}, received {{received}}",
        },
        userName: "User's name",
      },
    },
  },
});

z.setErrorMap(zodI18nMap);

z.string().parse(1) // => Expected string, received number

const schema = z.object({
  userName: z.string(),
});
schema.parse({ userName: 1 }) // => User's name is expected string, received number

BREAKING CHANGES

  • the argument type of makeZodI18nMap changes
export type MakeZodI18nMap = (option?: ZodI18nMapOption) => ZodErrorMap;

export type ZodI18nMapOption = {
  t?: i18n["t"];
  ns?: string | readonly string[]; // See: `Namespace`
  handlePath?: { // See: `Handling object schema keys`
    context?: string;
    ns?: string | readonly string[];
    keyPrefix?: string;
  }; 
};

zod-i18n-map-v1.9.0

19 Dec 14:20
bbf1307
Compare
Choose a tag to compare

zod-i18n-map-v1.9.0 (2022-12-19)

Features

  • make the specification of interpolation.skipOnVariables omissible (a0d4ee8)

zod-i18n-map-v1.8.0

18 Dec 03:42
c05c3b2
Compare
Choose a tag to compare

zod-i18n-map-v1.8.0 (2022-12-18)

Features

  • add es (spanish) locale (83afe58)

zod-i18n-map-v1.7.3

16 Dec 17:01
Compare
Choose a tag to compare

zod-i18n-map-v1.7.3 (2022-12-16)

Bug Fixes

  • add issue.exact to ar locale (7a22a5f)

zod-i18n-map-v1.7.2

16 Dec 11:42
20d5bc2
Compare
Choose a tag to compare

zod-i18n-map-v1.7.2 (2022-12-16)

Bug Fixes

  • issue.exact case was missing and some quotations marks were missing (fr) (20d5bc2)

zod-i18n-map-v1.7.1

15 Dec 12:42
d1e2a64
Compare
Choose a tag to compare

zod-i18n-map-v1.7.1 (2022-12-15)

Bug Fixes

  • issue.exact case was missing and some quotations marks were missing (d1e2a64)

zod-i18n-map-v1.7.0

13 Dec 13:58
074554d
Compare
Choose a tag to compare

zod-i18n-map-v1.7.0 (2022-12-13)

Features

  • support for Icelandic language (074554d)

zod-i18n-map-v1.6.0

13 Dec 11:25
0b1ca69
Compare
Choose a tag to compare

zod-i18n-map-v1.6.0 (2022-12-13)

Features

  • add translations for z.number().finite() (zod v3.20) (e1d1665)
  • add translations for z.string().datetime() (zod v3.20) (bda3aeb)