logaretm / vee-validate

✅ Painless Vue forms
https://vee-validate.logaretm.com/v4
MIT License
10.74k stars 1.26k forks source link

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

Open Uleertel opened 1 month ago

Uleertel commented 1 month ago

What happened?

I have a vuejs 3.4 application currently using vee-validate & vee-validate/rules libraries in version 4.12.8. I tried to update these libraries to the latest 4.13.2 but when loading the application I have an error in the brother : "Error: Extension Error: The validator 'all' must be a function."

The error is happening when I'm loading all the rules as explained on the npm page https://www.npmjs.com/package/@vee-validate/rules with the following code :

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

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

Reproduction steps

  1. create a vuejs application
  2. use the code provided above

Version

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

What browsers are you seeing the problem on?

Relevant log output

No response

Demo link

couldn't make codesandbox work...

Code of Conduct

tfoxkiu commented 3 weeks ago

Not sure when it was changed, but now instead of:

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

you have to do:

import { all as rules } from '@vee-validate/rules';
Uleertel commented 3 weeks ago

Thanks it seems to do the trick. I hope someone from the project will see this and update the npm page.