Lang pt_BR may be broken
See original GitHub issueI tested other langs but only pt_BR is giving an error. My code is like this:
let Validator = require('validatorjs');
Validator.useLang('pt_BR');
let rules: any = {
nome: 'required|between:5,100',
data_nascimento: ['required', 'regex:([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))'],
cpf: 'required|size:11',
sexo: 'required|size:1',
escola_id: 'required'
}
let validation = new Validator(aluno, rules);
validation.setAttributeNames({
data_nascimento: "data de nascimento",
escola_id: "escola"
});
if (validation.fails()) {
console.log(validation.errors.all())
}
And the error:
Cannot read property 'hasOwnProperty' of undefined
at Messages._getAttributeName (path/node_modules/validatorjs/src/messages.js:52:41)
at Messages._replacePlaceholders (path/node_modules/validatorjs/src/messages.js:136:27
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9
Top Results From Across the Web
Lang pt_BR may be broken · Issue #299 - GitHub
I tested other langs but only pt_BR is giving an error. My code is like this: let Validator = require('validatorjs'); Validator.
Read more >How to set HTML lang attribute dynamically on NextJs ...
I believe the best solution here is to use a custom ./pages/_document.js file and override the document itself. import Document, { Html ...
Read more >[root tip] [How To] Troubleshooting locale errors - Tutorials
I have written this using my system's locale - en_DK for messages and da_DK for the rest of the system. Check locale settings...
Read more >BROKEN HOST in Licensing Information Occurs ... - Tableau
Activation becomes broken intermittently (**BROKEN** HOST Trust Flags in ... BROKEN HOST may occur in licensing information when a Tableau ...
Read more >Supported languages and browsers | Docs - Twitter Developer
Pages which define an unsupported script or region will be mapped to the closest available language: e.g. pt-BR will use pt if Portuguese...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mtcarvalho I checked the resource files. Probably the same problem like last year. Just add the “attributes : {}” on the pt-br file and it will work.
Hello, mister @CFCSystem, We had the same problem here trying to use the Lang method but I came around with a temporary solution, that is to pass an object with all translations (you can copy from the very Lang pt_BR they supply) and pass it as argument as “custom attributes” in the new Validator.
E.g. let validation = new Validator(aluno, rules, { …customAttributes })
While this is not a real solution, it worked out just fine.