-
-
Notifications
You must be signed in to change notification settings - Fork 279
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
Validator.register: TypeError: Cannot set properties of undefined #467
Comments
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;
},
.... |
I have this issue as well. seems your fix does the trick! |
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',
},
},
}); |
Same issue here,
This is when I build this using esbuild and try to run it, I have this piece of code that fails
version - "3.22.1" debugged the code and this this.messages[lang][attribute] = message;
|
this problem still persists in this library. |
What version of this package are you using?
"validatorjs": "^3.22.1",
What operating system, Node.js, and npm version?
MacOs 12.4
Node v18.13.0
Yarn 1.22.19
I'm using Vite for the build.
What happened?
I have following code:
This gives me error on the
Validator.register
line above:In the source code it errors on line:
this.messages[lang][attribute] = message;
So probably means this.messages[lang] was never set.
What did you expect to happen?
No errors.
Are you willing to submit a pull request to fix this bug?
Maybe if it's simple.
The text was updated successfully, but these errors were encountered: