cedvdb / phone_numbers_parser

Dart phone number parser, based on libphonenumber and PhoneNumberKit.
https://pub.dev/packages/phone_numbers_parser
MIT License
63 stars 32 forks source link

With the 5.0.0 version, it's impossible to validate phone numbers for an arbitrary country #24

Closed Zverik closed 2 years ago

Zverik commented 2 years ago

Since 5.0.0, instead of specifying a country ISO code as string, this library requires using the generated enum. This is fine when a country is known at compilation time, but for multi-national apps it breaks the workflow. All I know is a string. Even if it were a enum, it would be a different enum, coming from a different library.

Is there a way to use string ISO codes with this library?

cedvdb commented 2 years ago

Do I understand correctly that you need to transform a string from 'US' to IsoCode.US dynamically ?

Yes, Dart enums are spawnable with a String, I'll add something to the documentation so it's clearer.

in the mean time you can use Enum.values.byName(your_string) so in this case IsoCode.values.byName('US')

cedvdb commented 2 years ago

I've updated the readme with an example. Feel free to reopen if that's not your issue