Git Product home page Git Product logo

nuxt-zod-i18n's People

Contributors

danielroe avatar kylexie avatar xibman avatar zalweny26 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nuxt-zod-i18n's Issues

How to use .. example don't work

Description

I can't even find the nuxt-zod-i18n import in your playground. On my side, the installation and configuration settings don't work. Errors are not translated. Do you have a working example in a codePen or something?

Possibility of custom error message without duplicating validation logic.

Description

Hello, is it possible to have a custom error message for specific fields, without redefining the validation logic?

I have this schema

export const userSchema = z.object({
    chosenDate: z
        .array(z.enum(['saturday', 'sunday']))
        .min(1)
        .max(2),
    peopleAmount: z.enum(['1', '2', '3', '4', '5', '6', '7', '8']),
    email: z.string().email(),
    marketingPermission: z.literal(true),
    termsAndConditions: z.literal(true),
});

how can I have a custom error message for the marketingPermission and termsAndConditions, without globally overriding the invalid_literal error code? I mean I want two different error messages for both, but the same validation.

I know that I could do something like this:
marketingPermission: z.literal(true).refine((value) => value === true, { params: { i18n: 'acceptMarketingPermissionError' } })
but I don't like this approach because I don't want to redefine the validation logic of z.literal.
Do you understand my issue?

Thank you and kind regards🙂

Unable to override translation with discriminated union

Description

Hi, I'm trying to override an error translation but my schema is a z.discriminatedUnion and I don't understand what I'm doing wrong, I'm still having the default error from the translated errors of this library.
That's the schema:

const triggerSchema = z.discriminatedUnion('type', [
	likeTriggerSchema,
	dislikeTriggerSchema,
]).refine(data => ['dislike', 'like'].includes(data.type), {
	path: ['type'],
	params: { i18n: 'errors.trigger.unknownType' },
})

I'm using Nuxt UI, so the schema is used by the Form component.

Error `Cannot destructure property 't' of 'i18n' as it is undefined.`

Environment



Version

v1.3.0

Reproduction

https://stackblitz.com/edit/nuxt-starter-dpc9kz?file=nuxt.config.ts

Description

I installed nuxt-zod-i18n after I had already been using @nuxtjs/i18n for a while. I added it to the modules in the nuxt.config.ts and got the error that 't' of 'i18n' is undefined. and therefore cannot be accessed.

The same error happened in a minimal stackblitz reproduction (also linked above).

Additional context

No response

Logs

[nuxt] [request error] [unhandled] [500] Cannot destructure property 't' of 'i18n' as it is undefined.
  at ./node_modules/.pnpm/[email protected][email protected]/node_modules/nuxt-zod-i18n/dist/runtime/plugin.mjs:10:11
  at ./virtual:nuxt:/Users/zoeykaiser/Documents/Development/Sidestream/dikoma/.nuxt/plugins/server.mjs:52:89
  at Module.executeAsync (./node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:111:19)
  at setup (./virtual:nuxt:/Users/zoeykaiser/Documents/Development/Sidestream/dikoma/.nuxt/plugins/server.mjs:52:65)
  at ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/app/nuxt.js:116:60
  at fn (./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/app/nuxt.js:191:44)
  at Object.callAsync (./node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:68:55)
  at ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/app/nuxt.js:193:56
  at Object.runWithContext (./node_modules/.pnpm/@[email protected]/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3998:18)
  at callWithNuxt (./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/app/nuxt.js:193:24)

Add custom code

Description

In my instance of @nuxtjs/i18n, I use different code from the base ones (i.e. it-IT, en-GB, etc...) so this module doesn't find the relative translation path. It could be added, in the configuration inside nuxt.config, the chance to map the json files in the module, with specific user-defined code.

code: file.replace('.json', '')

Additional context

No response

Unable to load `i18n.config.ts` config file

Environment

  • Operating System: Darwin
  • Node Version: v20.2.0
  • Nuxt Version: 3.9.3
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Version

v1.4.0

Reproduction

Description

Actually, is not possible to use nuxt-zod-i18n with external @nuxtjs/i18n configuration file like i18n.config.ts.

nuxt-zod-i18n only load i18n configuration from the nuxt.config.ts file. See this line:

i18nOptions = (nuxt.options as any).i18n

We need to be able to load the configuration of this external file, based on the path defined in the Nuxt configuration or './i18n.config.ts' by default.

export default defineNuxtConfig({
  // ...
  i18n: {
    vueI18n: './my-i18n.config.ts' // optional, './i18n.config.ts' by default 
  }
})

Additional context

No response

Logs

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.