Comments (5)
I'm facing the same issue, aliasing the module to point to the dist
directory works fine for me:
import { defineConfig } from 'vite';
export default defineConfig({
resolve: {
alias: {
validatorjs: 'validatorjs/dist/validator.js',
},
},
});
from validatorjs.
I'm having similar issues when switching over to Vite from Webpack, while using MobX React Form and ValidatorJS as the validator. Setting a field to "required", and attempting to validate it returns the following:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'def')
at Messages._getTemplate (messages.js:103:29)
at Messages.render (messages.js:82:25)
at Validator._addFailure (validator.js:151:29)
at Validator.check (validator.js:73:16)
at Validator.passes (validator.js:494:17)
at DVR2.validateFieldSync (DVR.js:126:22)
at DVR2.validateField (DVR.js:88:12)
at Validator.js:160:33
at _createBaseFor.js:17:11
at baseForOwn (_baseForOwn.js:13:20)
from validatorjs.
I'm facing the same issue, aliasing the module to point to the
dist
directory works fine for me:import { defineConfig } from 'vite'; export default defineConfig({ resolve: { alias: { validatorjs: 'validatorjs/dist/validator.js', }, }, });
This solution worked until I called useLang
method.
Needs a fix to handle language.
from validatorjs.
My suspicion, though I don't know much about "bundling", is that, I believe, the library attempts to load "language files" via require_method('./lang/' + lang)
and that require_method = require;
I suspect the issue is that the language files are not being bundled by Vite?
I'm not sure how/if I can:
- tell Vite to bundle the resource files of a named NPM ??
- fork the NPM and add some vite-specific configuration ??
- fork the NPM and add some additional NPM or JS configuration such that its files bundle correctly (with Vite or with all bundlers??)
Pointers to docs or concepts or appropriate terminology for what I'm looking at here would be GREATLY appreciated!!
from validatorjs.
Not the best, but with yarn, package.json
can be patched to change https://github.com/mikeerickson/validatorjs/blob/master/package.json#L21
from "main": "./src/validator.js",
to "main": "./dist/validator.js",
from validatorjs.
Related Issues (20)
- My email address is in your security policy HOT 2
- Custom replacements not working for custom rules HOT 1
- Wildcard object validation supported? HOT 1
- Validator.passes() throws an exception when using in AWS Lambda deployed with AWS CDK HOT 13
- An error with a valid regexp HOT 1
- Local Server URL Marked as Invalid HOT 2
- Other validations are being ignored when value is null HOT 3
- Accept only keys defined in rule object HOT 1
- Accessing request object inside register() registerAsync() HOT 1
- can't create custom message by mask .*. HOT 1
- [Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'messages.def')] HOT 2
- TypeError: Cannot read properties of undefined (reading 'def') HOT 1
- Validator.registerAsync() argument message should be optional
- Validator.registerAsync() callback documentation
- Ability to register a rule per validator instance
- Is project still maintained HOT 6
- Validator.register: TypeError: Cannot set properties of undefined HOT 5
- Required_if not working with numbers
- required_without accepts empty arrays but laravel doesn't
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from validatorjs.