#Error using JSONSchema for create a Schema
1 messages · Page 1 of 1 (latest)
you need to understand this and scope and probably use an arrow function not a class one
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this
https://developer.mozilla.org/en-US/docs/Glossary/Scope
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
🤷🏿♀️ not understand!
If you want this code:
validator: (cpf: string) => {
return isCpfValid(cpf);
}
To call this class method:
isCpfValid(cpf: string): boolean {
return cpfValidator.isValid(cpf);
}
then you must use this.isCpfValid
same error 🤷🏿♀️
Show code, so complete code. So error, show complete error message
you have too many things named isCpfValid
Use differnet names. review your code again and see if you can make better sense about what is happening and what you want to have happen.
import { validator as isCpfValid, cpf as cpfValidator } from 'cpf-cnpj-validator';
isCpfValid(cpf: string): boolean {
Which one is the real isCpfValid you want called? where when?
if it is the same error then you didn't change the names
unless you know what you are doing that is not a likely road to success.
cpf-cnpj-validator is not a library I have ever used, it is 3 years out of date, and no where in the README (which admittedly I cannot read) does it show
import { validator } from 'cpf-cnpj-validator'
It does show:
import validator from 'cpf-cnpj-validator';
and
import { cpf } from 'cpf-cnpj-validator';
But those { curly brackets } are significant
How modules work in TypeScript
That seems quite unlikely to work.
If you want the export default validator from cpf-cnpj-validator then you MUST do:
import validator as cpfV from 'cpf-cnpj-validator';
you cannot do:
import { validator as cpfV } from 'cpf-cnpj-validator'
Please read the TypeScript default exports documentation I linked above
Then you probably aren't going to be able to do this. You need too much understanding of build systems and import systems for me to teach here. Sorry.