Comments (5)
This edit fixes my issue:
// lang.js
...
_setRuleMessage: function(lang, attribute, message) {
this._load(lang);
if (message === undefined) {
message = this.messages[lang].def;
}
// Added this line
if (typeof this.messages[lang] === 'undefined') {
this.messages[lang] = {}
}
this.messages[lang][attribute] = message;
},
....
from validatorjs.
I have this issue as well. seems your fix does the trick!
hopefully it can be patched in soon
from validatorjs.
I'm facing the same issue, this workaround works fine for me:
import { defineConfig } from 'vite';
export default defineConfig({
resolve: {
alias: {
validatorjs: 'validatorjs/dist/validator.js',
},
},
});
from validatorjs.
Same issue here,
undefined ERROR Uncaught Exception {"errorType":"TypeError","errorMessage":"Cannot set properties of undefined (setting 'notEmptyString')","stack":["TypeError: Cannot set properties of undefined (setting 'notEmptyString')"," at Object._setRuleMessage (file:REDACTED**)"," at Validator.registerImplicit (file:REDACTED**)"," at file:REDACTED**" at ModuleJob.run (file:REDACTED**)"]}
This is when I build this using esbuild and try to run it,
I have this piece of code that fails
import ValidatorJS from "validatorjs"; ValidatorJS.registerImplicit("notEmptyString", validateEmptyString, "The :attribute can not be empty string");
version - "3.22.1"
debugged the code and this this.messages[lang][attribute] = message;fails at
this.messages[lang] being undefined;
undefined ERROR Error: Cannot find module './lang/en'
at
_load: function(lang) { if (!this.messages[lang]) { try { var rawMessages = require_method("./lang/" + lang); this._set(lang, rawMessages); } catch (e) { console.error(e, 'some error in load') - // this is where the error comes from } } },
from validatorjs.
this problem still persists in this library.
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
- Vite + React - leads to undefined error HOT 5
- 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
- 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.