Skip to content
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

corrected the phone validator function for text input in form widget. #1439

Merged
merged 3 commits into from
Jun 7, 2024

Conversation

TheNoumanDev
Copy link
Member

@TheNoumanDev TheNoumanDev commented Jun 6, 2024

The phone validator function was coming from the following package:
image

and was accepting strings greater then 7 and less then 15 consisting only of digit with regExp "^\d{7,15}$" which is correct but the bug was in the function.

image
the function is removing the non-digit number then checking the phoneExp thats why it is returning true.

so am just using simple regExp function that will do the work using the above mentioned Expression and the message doesnt mattar, we are just returning the bool.

@TheNoumanDev TheNoumanDev requested a review from amin-nas June 6, 2024 19:43
Copy link
Contributor

@vusters vusters left a comment

Choose a reason for hiding this comment

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

Please do this:

  1. Create a ValidationUtils class with validatePhone() method and put the code there.
  2. Ask GPT to write a few unit tests inside ValidationUtils_test.dart.
  3. inside your phone() just return validatePhone()

@TheNoumanDev
Copy link
Member Author

  1. Above i just showed function from a package, code for validatePhone() was already implemented with class as InputValidator in Util folder (https://github.com/EnsembleUI/ensemble/blob/nouman/modules/ensemble/lib/util/input_validator.dart#L13) so ig there was not need of creating another class. i just edited the existing function, not added a new one.
  2. For validation, there were already file existed named validators_test.dart, so i just write unit tests for phone function validation. (https://github.com/EnsembleUI/ensemble/blob/nouman/modules/ensemble/test/validators_test.dart).

(Sorry in advance if i understood wrong😅).

@TheNoumanDev TheNoumanDev requested a review from vusters June 7, 2024 19:50
@TheNoumanDev TheNoumanDev merged commit 5c685e9 into main Jun 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants