-
Notifications
You must be signed in to change notification settings - Fork 823
Does IsMobilePhone accept an array ? #1866
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
Comments
”class-validator": "^0.14.0" |
Could you provide a simple reproduction of this? This works for me: class MyClass {
@IsMobilePhone(['fi-FI', 'nn-NO'])
phone: string;
}
const plain = { phone: '+4744664477' };
const instance = await plainToInstance(MyClass, plain);
const errors = await validate(instance);
console.log(errors); // [] |
the type |
my simple is like yours. which version are you using? this is my simple. src/validator.ts file will show you my problem("Argument of type 'string[]' is not assignable to parameter of type 'MobilePhoneLocale'."). |
I was using version 0.13.2 of I created a new project and installed everything fresh with 0.14.0, and now I am getting the same type error, even if the Now I've started digging into it and I'm noticing that all the ValidatorJS argument types aren't resolved properly in my project that uses 0.13.2. Obviously typescript wouldn't complain if this type just defaulting to A quick look at another decorator, IsEmail yields the same problem with an unresolved type. Is this consistently the case? I can't seem to find something in the changes since 0.13.2 that would explain how the types didn't work correctly in 0.13.2 but started working in 0.14.0. Could it be that @types/validator fixed something in its types which isn't visible in our Have you experienced this, @NoNameProvided? |
When I look at my
I suspect a change occured somewhere between version 13.7.0 and 13.7.10 of |
Any news on this problem ? I got it too |
I think this is a bug of V0.14.0, when you use validator@^13.9.0 and it is installed latest version 13.11.0 while isMobilePhone of validator is break and not use locale as array input. Please check and fix. Thanks |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I was trying to...
@IsMobilePhone(['sk-SK', 'sr-RS']) mobile: string;
The problem:
it show a message which is 'type string[] can’t pass to type MobilePhoneLocale'. but in isMobilePhone.d.ts, the annotation says 'locale is either an array of locales, or one of ...'
`
`
so how can i use IsMobilePhone and pass an array to param locale
The text was updated successfully, but these errors were encountered: