Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Add validate number without region code #73

Merged
merged 3 commits into from Aug 4, 2022
Merged

Add validate number without region code #73

merged 3 commits into from Aug 4, 2022

Conversation

deandreamatias
Copy link
Contributor

@deandreamatias deandreamatias commented Aug 2, 2022

Connection with issue(s)

Close #64

Solution description

If don't pass region code to validator, try validate a complete number

Video demo

phone_number.64.solved.mp4

To Do

  • Read contributing guide
  • Check the original issue to confirm it is fully satisfied
  • Add solution description to help guide reviewers
  • Add unit test to verify new or fixed behaviour
  • If apply, add documentation to code properties and package readme

@deandreamatias
Copy link
Contributor Author

@ooglek take a look if this should be a solution
I don't test this yet, but I can do in this weekend maybe

@ooglek
Copy link

ooglek commented Aug 2, 2022

That looks great! If I do not pass a region code, still validate if the number is valid!

Thank you for digging into this. I can try to test it as well.

README.md Outdated Show resolved Hide resolved
lib/src/phone_number_util.dart Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@iamsahilsonawane
Copy link
Member

I understand that it's a WIP, still have added these comments as reference

@deandreamatias deandreamatias changed the title WIP: Add validate number without region code Add validate number without region code Aug 3, 2022
@deandreamatias
Copy link
Contributor Author

I tested in Android with random numbers and works fine

Copy link
Member

@iamsahilsonawane iamsahilsonawane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@deandreamatias deandreamatias merged commit 8bda194 into main Aug 4, 2022
@ooglek
Copy link

ooglek commented Aug 7, 2022

When will this get pushed in a version bump? Thanks for fixing!

@deandreamatias
Copy link
Contributor Author

When finish the readme refactor

@ooglek
Copy link

ooglek commented Aug 8, 2022

This breaks validate() on IOS

private func validate(_ call: FlutterMethodCall, result: FlutterResult){
guard
let arguments = call.arguments as? [String : Any],
let number = arguments["string"] as? String,
let region = arguments["region"] as? String
else {
result(FlutterError(code: "InvalidArgument",
message: "The 'string' argument is missing.",
details: nil))
return
}
let isValid = kit.isValidPhoneNumber(number,withRegion: region);
let res:[String: Bool] = [
"isValid": isValid
]
result(res)
}

Passing string as +5518988012364 and region as `` (empty string) and getting the error
PlatformException(InvalidArgument, The 'string' argument is missing., null, null)

@ooglek
Copy link

ooglek commented Aug 8, 2022

@deandreamatias Looks like the IOS Swift Code needs modification as well.

@deandreamatias
Copy link
Contributor Author

Open a issue please

@ooglek
Copy link

ooglek commented Aug 9, 2022

Done, Issue #82

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with Determining the ISO3166 Country Code given a phone number, validation
3 participants