class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

fix: documentation incorrect for @IsPhoneNumber decorator in v0.13.0

Open asmimo opened this issue 5 years ago • 4 comments

Description

v0.13.0 throws error on code using "@IsPhoneNumber" when passing "ZZ" or null as parameter

asmimo avatar Jan 12 '21 03:01 asmimo

Can you try passing undefined?

NoNameProvided avatar Jan 12 '21 09:01 NoNameProvided

undefined works but is it same as "ZZ"

asmimo avatar Jan 12 '21 15:01 asmimo

I have updated the documentation of the function in 1fa074d63078346238a6a7becf1f698b09a67350.

Undefined works but is it same as "ZZ"?

If you pass undefined or better doesn't provide the parameter, then the data must provide the international calling code (eg: +1), otherwise the validation will fail. So an example:

  • +36 30 111 1111 - parsing this number will work because it's a valid phone number and the calling code is provided
  • 06 30 111 1111 - parsing this number will fail, (the number is valid and in the local Hungarian format) but without providing the area code the lib won't recognise it
  • 06 30 111 1111 with HU - parsing this will work because it is a valid local number and the region was provided so the lib will understand it as well

NoNameProvided avatar Jan 13 '21 12:01 NoNameProvided

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.

github-actions[bot] avatar Feb 14 '21 00:02 github-actions[bot]