Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The validator 'default' must be a function error in prod when importing all @vee-validate/rules #4470

Closed
1 of 5 tasks
AndColla opened this issue Sep 12, 2023 · 4 comments
Closed
1 of 5 tasks

Comments

@AndColla
Copy link

What happened?

I have a nuxt plugin to import all the @vee-validate/rules

import AllRules from '@vee-validate/rules';

Object.keys(AllRules).forEach(rule => {
  defineRule(rule, AllRules[rule]);
});

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp
});

When I try to use this plugin in dev mode it works just fine, but if I try to build and run it in prod mode i get The validator 'default' must be a function.

This error appeared after the 4.11.4 update

Reproduction steps

No response

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

[nuxt] [request error] [unhandled] [500] Extension Error: The validator 'default' must be a function.
  at async eval (./server/chunks/handlers/renderer.mjs:46:22)  
  at async Object.eval [as handler] (./server/chunks/nitro/node-server.mjs:2177:19)  
  at async Server.toNodeHandle (./server/chunks/nitro/node-server.mjs:2366:7)

Demo link

https://stackblitz.com/edit/nuxt-starter-fkj1dc?file=plugins%2Fvee-validate.js

Code of Conduct

@logaretm
Copy link
Owner

Seems like the production build isn't handling default and named exports at the same time. Will be a breaking change but I will tag it in the next patch release.

@corradopetrelli
Copy link

Same issue with Vue 3 and vee-validate 4.11.8 in production

@zsq44
Copy link

zsq44 commented Jun 25, 2024

Same issue with Vue 3 and vee-validate 4.13.1 in production

@Uleertel
Copy link

Uleertel commented Aug 8, 2024

Same issue with Vue 3 and vee-validate & vee-validate/rules 4.13.2
Can you please consider this issue since it breaking the behavior described on https://www.npmjs.com/package/@vee-validate/rules

import { defineRule } from 'vee-validate';
import * as rules from '@vee-validate/rules';

Object.keys(rules).forEach(rule => {
  defineRule(rule, rules[rule]);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants