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

feat(develop): added phonenumber type validator to IsPhoneNumber.ts

Open Sylar-3 opened this issue 1 year ago • 3 comments

Description

Added new feature to check the phonenumber type using .getType() method from libphonenumber-js

Checklist

  • [x] the pull request title describes what this PR does (not a vague title like Update index.md)
  • [x] the pull request targets the default branch of the repository (develop)
  • [x] the code follows the established code style of the repository
  • npm run prettier:check passes
  • npm run lint:check passes
  • [ ] tests are added for the changes I made (if any source code was modified)
  • [x] documentation added or updated
  • [x] I have run the project locally and verified that there are no errors.

Sylar-3 avatar Nov 21 '24 13:11 Sylar-3

Please check this change and let me know if anything needs to be modified. Since it is an optional parameter to the function it shouldn't break any existing applications. The new feature relies on the provided options in the [https://www.npmjs.com/package/libphonenumber-js]. Hopefully this will make validating phone number types more clear since it will specify the phone number type rather than using a default value in the lib.

Sylar-3 avatar Nov 21 '24 13:11 Sylar-3

Hi @Sylar-3, what is the benefit of defining types inside the library instead of using original types from libphonenumber-js?

shevchenkonik avatar Nov 25 '24 13:11 shevchenkonik

Hi @Sylar-3, what is the benefit of defining types inside the library instead of using original types from libphonenumber-js?

Thanks @shevchenkonik for your insight, actually there is no value in this as you just said, but this will make it easier for developers to check these types in the validator itself rather than going to the library and search for them.

if there is any other question or issue please let me know since this pull request might help a lot in validating some APIs I'm using.

Sylar-3 avatar Nov 25 '24 13:11 Sylar-3