-
Notifications
You must be signed in to change notification settings - Fork 247
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
Flutter: Custom Phone Number Form Field accepts empty value still after setting required
argument as true
#4079
Comments
required
argument set as true
required
argument as true
@kavienanj - Thanks for opening this and providing these details. We will attempt to reproduce this. |
I was able to reproduce this. I will mark this as a bug and we will look into a fix. |
A fix for this was just merged. A new version should be released with this fix in the next week or two. I will let you know when that happens. |
Cool, I saw the merged PR. I have a doubt. Lets say a user selects +94 from the country code, and still inputs the country code again in the input field. How does the validation performs after this version? will it be the same or different? |
@kavienanj - I think you are correct. This would result in a change in behavior as the number would still be considered valid. I will revert the fix and we will look into an alternative solution for this. |
Please, can anyone make an update on the progress of this fix? |
Hi @kavienanj - Apologies for the delay. This is in our backlog our issues to resolve. I do not have an estimate for when it will be addressed. |
This is still in our backlog of issues to address. I wanted to callout one possible workaround for anyone facing this issue. It should be possible to create a custom form field for phone number. I recognize that this is not ideal, but wanted to note it for anyone that is blocked by this. We will post here when we have updates on a fix. |
Where can we find the specific guide on how to create custom form fields? |
There are two options:
|
Before creating a new issue, please confirm:
On which framework/platform are you having an issue?
Flutter
Which UI component?
Authenticator
How is your app built?
Flutter
What browsers are you seeing the problem on?
iOS (Flutter), Android (Flutter)
Which region are you seeing the problem in?
No response
Please describe your bug.
When adding the phone number field to a form (eg: SignUpForm) with the
required
argument set astrue
, the validator function still treats the field as optional. Which allows the form to be submitted with an empty phone number. The field hint seems to work perfectly. So I assume therequired
argument is not being passed into thevalidatePhoneNumber(bool isOptional, ... )
function properly. This assumption is because when I copied the defaultvalidatePhoneNumber
from the library, and setisOptional
argument as `true'. Then I passed this rewritten validator function to the form field, it worked.What's the expected behaviour?
When adding the phone number field to a form (eg: SignUpForm) with the
required
argument set astrue
, if a user trys to submit the form leaving the phone number field empty, the validator should return the 'Phone Number field must not be blank' error text and stop the user from submitting.Help us reproduce the bug!
In main.dart file
the
AWSAmplifyService.configure()
runs the necessary Amplify/Cognito configurations.AppRouterConfig.router
is GoRouter Configurations.Run the Flutter app and Try submitting the
SignUpForm
. It Should submit with empty phone number.Now I copied the
validatePhoneNumber
function and rewrote it as follows,And pass the new rewritten validator as an argument for
SignUpFormField.phoneNumber
Now Try submitting the
SignUpForm
. It should show an error when user trys to submit with empty phone number.Code Snippet
Console log output
No response
Additional information and screenshots
The text was updated successfully, but these errors were encountered: