Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
514 views
in Technique[技术] by (71.8m points)

vue.js - Vee Validate Custom Rules not working in Laravel. Uncaught (in promise) Error: No such validator 'xxx' exists

I have set up a Laravel with VueJs as a SPA. Also I integrated Vee Validate to validate all my form inputs. The default rules work as expected. However I don't seem to get my custom rules to work. I always get the error message:

Uncaught (in promise) Error: No such validator 'xxx' exists.

I followed this tutorial: https://medium.com/@rafaelogic/creating-a-custom-rule-in-vue-vee-validate-83777b9a5126

Here I have imported Vee Validate and the custom rules in my app.js file app.js

Inside validators/index.js I have the following validators/index.js

That is the custom "rule" - just for testing inside validators/rules/number_of_electrical_feeds.js.

number_of_electrical_feeds.js

And that is the component that tries to use the rule - inside js/components/LuminaireLine/Form.js Form.js

What's the error I'm making?

question from:https://stackoverflow.com/questions/65926757/vee-validate-custom-rules-not-working-in-laravel-uncaught-in-promise-error-n

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should unify your imports, the vee-validate and vee-validate/dist/vee-validate.full.esm are two different dist files and thus each maintains their own rules and ecosystem.

You need to decide which version of vee-validate you want to use and only import everything from that dist

That includes extend, and the components and basically any vee-validate API you will import.

import { ValidationProvider, ValidationObserver, extend } from 'vee-validate/dist/vee-validate.full.esm';

You can configure a webpack alias to make this easier for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...