Open jianmin-chen opened 2 years ago
It is happening here too...
I don't have too much context from the isMobilePhone file but I guess there's tow export there. The default and a locales one.
The object returned looks like that:
{
default: [Function: isMobilePhone],
locales: [...]
}
@jianmin-chen if it helps, you can still use:
import validator from "validator";
validator.isMobilePhone('999...'); // false | true
Indeed isMobilePhone.js
has two exports, default and locales.
In index.js
it imports the following and I think you need to do the same.
https://github.com/validatorjs/validator.js/blob/cfcf9113c69b97477c409909a8729fa8efa0d595/src/index.js#L81
The same is true for all validators that use locales.
Since it is not a bug, I think it would be better to add a note in the readme about the usage of some validators.
What do you think?
I got the same issue with JEST, could anyone please help?
I got the same issue with JEST, could anyone please help?
This seems to be unrelated. You probably just need to install validator through npm/pnpm/yarn
Describe the bug I'm running the latest version of the library and
isMobilePhone
is not defined. I imported the validator functions as so:isEmail
works, but usingisMobilePhone
returns an error. Is there something I'm not aware of? I searchednode_modules/validator
andisMobilePhone
does not appear to be in eitheres/lib
orlib/util
.Examples
Additional context Validator.js version: 13.7.0 Node.js version: 16.14.2 OS platform: Windows